Intent.EXTRA_LOCAL_ONLY not working

What I'm trying to do in my application is to allow the user to select a picture from their phone gallery. The code I use is as follows:

Intent intentBrowseFiles = new Intent(); intentBrowseFiles.setType("image/*"); intentBrowseFiles.setAction(Intent.ACTION_GET_CONTENT); intentBrowseFiles.putExtra(Intent.EXTRA_LOCAL_ONLY, true); startActivityForResult(Intent.createChooser(intentBrowseFiles,"Select Picture"), SHOW_GALLERY); 

Assuming:

 intentBrowseFiles.putExtra(Intent.EXTRA_LOCAL_ONLY, true); 

I thought that this would only lead to the galleryโ€™s intention, but instead the user will be left with the choice of their drive, Dropbox and other online accounts along with the local gallery ...

I do not want any other remote resources, is there something I am missing here?

+2
source share
1 answer

When you use an action with an intent, such as ACTION_GET_CONTENT , you tell the system to choose which application to open. If the user has not set a default for him, he will ask which application to use. The applications in the dialog box will show applications that have stated that they can handle this type of intent.

If you want to use an intent to trigger a specific action, you must call it by name. The problem here is that the gallery application can be named differently on different devices or even deleted.

Allow the user to choose his application, as a rule, correctly. This is definitely the โ€œAndroidyโ€ way to do it.

In any case, EXTRA_LOCAL_ONLY tells the receiving application that it should only return data that is present. This condition does not ensure compliance with this condition.

+3
source

All Articles