I have an example:
public List<Map<String, Object>> getAppOpeners(Intent intent) {
if (intent == null) {
return null;
}
List<Map<String, Object>> appinfos = new ArrayList<Map<String, Object>>();
ResolveInfo app = null;
List<ResolveInfo> mApps = new ArrayList<ResolveInfo>();
PackageManager pm = mContext.getPackageManager();
mApps = pm.queryIntentActivities(intent,
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT);
Iterator<ResolveInfo> it = mApps.iterator();
while (it.hasNext()) {
Map<String, Object> item = new HashMap<String, Object>();
app = it.next();
if (true) {
item.put("packname", app.activityInfo.packageName);
item.put("appname", app.loadLabel(mContext.getPackageManager()));
item.put("icon", app.loadIcon(mContext.getPackageManager()));
item.put("intent", intent);
appinfos.add(item);
}
}
return appinfos;
}
Codes are used to screen applications that can open a file using mimetype. Perhaps this is useful for you.
I'm sorry for my bad english
source
share