Reputation: 6912
I use below code to get share applications:
PackageManager packageManager = this.getPackageManager();
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("image/jpeg");
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(PhotoPath));
List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(sharingIntent, PackageManager.MATCH_DEFAULT_ONLY);
I get all applications chooser as below:
And I use below code to launch application:
"one" means the selected ResolveInfo.
Intent MySharingIntent = new Intent(Intent.ACTION_SEND);
MySharingIntent.setType("image/jpeg");
MySharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(PhotoPath));
MySharingIntent.setPackage(one.activityInfo.packageName);
startActivity(MySharingIntent);
If I select the item "Photo" or "Google+".
It will pop below dialog:
But I want to launch application "Photo" directly.
Without the second select dialog.
How can I do it?
Upvotes: 0
Views: 55
Reputation: 12512
You can do this by adding
intent.setComponent(new ComponentName("packagename of the activity","classname.java"));
But this is not recommended, you'll have to check first that "Photos" are indeed installed on the device.
Upvotes: 1