(Java) How to filter BaseAdapter? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

(Java) How to filter BaseAdapter?

Hi I'm doing an android app, but I don't know what to write under getFilter, because nothing works. Here there is the code of the arraylist: final List<Pair<String, List<String>>> appsWithPermission = new ArrayList<>(); final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List<ResolveInfo> apps = packageManager.queryIntentActivities(mainIntent, 0); Iterator itr = apps.iterator(); String strElement = ""; while (itr.hasNext()) { strElement = itr.next().toString(); if (strElement.contains("com.android")) { itr.remove(); } } for (ResolveInfo info : apps) { final ApplicationInfo applicationInfo = info.activityInfo.applicationInfo; final String appName = applicationInfo.packageName; final List<String> permissions = new ArrayList<>(); if (appName != null) { try { final PackageInfo packageInfo = packageManager.getPackageInfo(applicationInfo.packageName, PackageManager.GET_PERMISSIONS); final String[] requestedPermissions = packageInfo.requestedPermissions; if (requestedPermissions != null) { permissions.addAll(Arrays.asList(requestedPermissions)); } } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } } appsWithPermission.add(new Pair<>(appName, permissions)); } appsAdapter = new AppsAdapter(this, appsWithPermission); And this is the adapter to get the name of the apps (that I want to filter): String name = null; final PackageManager packageManager = mContext.getPackageManager(); name = (String) packageManager.getApplicationLabel(packageManager.getApplicationInfo(item.first, PackageManager.GET_META_DATA)); Thanks

22nd Mar 2018, 2:57 PM
faby GT
faby GT - avatar
2 Answers
0
Hi already tried this, but it doesn't work... can you help me?
6th Apr 2018, 12:40 PM
faby GT
faby GT - avatar