I'd like to get a list of apps on an Android device that are able to use (or to be launched with) PNG's.
I'm using this code:
final Inte开发者_StackOverflownt msg = new Intent(Intent.ACTION_MAIN, null);
msg.setType("image/png");
final List pkgAppsList = context.getPackageManager().queryIntentActivities(msg, 0);
But it return zero, which does not reflect reality. Any other ways of asking the framework about app abilities?
Pom
Try this instead
final Intent msg = new Intent();
msg.setType("image/png");
PackageManager pm = this.getPackageManager();
final List<ResolveInfo> apps = pm.queryIntentActivities(msg, 0);
Log.d("TTT", "Got " + apps.size());
for (int i = 0; i < apps.size(); ++i) {
Log.d("TTT", apps.get(i).loadLabel(pm).toString());
}
精彩评论