Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to choose specific app to handle intent

There are more than one app that could handle CROP intent, but I only want gallery to do it without choosing because other app like google+ will have really bad rendering resolution, and choosing process doesn't have good user experience.

Intent intent = new Intent("com.android.camera.action.CROP");
intent.setType("image/*");  
Intent i = new Intent(intent);
ResolveInfo res = list.get(0);
i.setComponent(new ComponentName(res.activityInfo.packageName,
               res.activityInfo.name));
startActivityForResult(intent, REQUEST_CROP_CAMERA);

So how could I specify Gallery app to handle CROP Intent without user's choice?

like image 606
Doge Avatar asked Nov 02 '22 05:11

Doge


1 Answers

you could specify the package in your intent:

 intent.setPackage("com.android.gallery");

this will set an explicit application package name

like image 167
donfuxx Avatar answered Nov 14 '22 06:11

donfuxx