EXTRA_LOCAL_ONLY tells only the receiving application that it should only return data that is present.
Google+ Photos stores both local and remote snapshots, and because of this, it is fixed with this extra. However, it seems to ignore wherever the called EXTRA_LOCAL_ONLY method EXTRA_LOCAL_ONLY set to true.
You can try removing G + Photos from the list manually (however this seems a bit hacked):
List<Intent> targets = new ArrayList<Intent>(); Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); List<ResolveInfo> candidates = getPackageManager().queryIntentActivities(intent, 0); for (ResolveInfo candidate : candidates) { String packageName = candidate.activityInfo.packageName; if (!packageName.equals("com.google.android.apps.photos") && !packageName.equals("com.google.android.apps.plus") && !packageName.equals("com.android.documentsui")) { Intent iWantThis = new Intent(); iWantThis.setType("image/*"); iWantThis.setAction(Intent.ACTION_GET_CONTENT); iWantThis.putExtra(Intent.EXTRA_LOCAL_ONLY, true); iWantThis.setPackage(packageName); targets.add(iWantThis); } } Intent chooser = Intent.createChooser(targets.remove(0), "Select Picture"); chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, targets.toArray(new Parcelable[targets.size()])); startActivityForResult(chooser, 1);
A few words of explanation: targets.remove(0) will remove and return the first Intent from the list of targets , so the selection will consist of only one application. Then, using Intent.EXTRA_INITIAL_INTENTS add the rest.
The code snippet is a modified version of this link .
Do not forget to check all conditions, for example, if at least one application is available, etc.
source share