我想添加activity(com.myapp.launcher.settings)到空的ArrayList中:
ArrayList<ResolveInfo> selectedApps = new ArrayList<ResolveInfo>(); selectedApps.add(/*WHAT GOES IN HERE?*/);
但是我不知道怎么获取ResolveInfo对象。
我试过使用一个工作环境,将所有的应用循环一遍需找activity,实现之后发现这种方法不是很好用。
// Get an array list of all apps ArrayList<ResolveInfo> allApps = (ArrayList<ResolveInfo>) pm.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED); for(final ResolveInfo app : allApps) { // If it's name is "com.myapp.launcher.settings" add it if(app.activityInfo.name.equals("com.myapp.launcher.settings")) { selectedApps.add(app); } }
心有法竹
相关分类