开发者

Android: Listing app intents able to use png's

开发者 https://www.devze.com 2023-02-04 12:17 出处:网络
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'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());
}
0

精彩评论

暂无评论...
验证码 换一张
取 消