I have a function in my app that let's people share content.
The way it usually works is:
Device asks user to choose an app to handle the Intent
. The user can choose between 'just once' or 'always'.
On some Samsung devices, e.g. Galaxy S6, the 'just once' and 'always' options are missing, after selection of an app this app becomes the standard for that event.
This even leads to my app being freshly installed, when trying to share, the user is not asked at all, the Intent
is just handled by the app that the user selected for sharing when sharing from another app!
This problem with some Samsung devices is documented here and here.
This is how I construct my simple intent:
Intent intent = ShareCompat.IntentBuilder.from(this)
.setSubject("mySubject")
.setText("myText")
.setType("text/plain")
.setChooserTitle("myChooserTitle").getIntent();
startActivity(intent);
I also tried:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "myText");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "mySubject");
sendIntent.setType("text/plain");
startActivity(sendIntent);
My question is: can I do anything from my code to prevent this or do I have to tell my users not to buy a Samsung next time?
The process used to be much more complicated, but Google has turned managing default apps into an effortless task. It’s baked right into the settings. Just go into your Settings app, select Apps & notifications, click on Advanced, and then go into Default apps.
Permissions granted will override the "Default app permissions" policy for the selected apps. Set the Permission state for each permission. You can choose from Prompt, Auto grant, or Auto deny. If the managed app supports configuration settings, the Configuration settings format dropdown box is visible.
Fact is, only one app can be the default app that opens up when you launch a file type or protocol on your device. If none has been set, you will instant get an action prompt where you are asked to select the app you want to open your selection with.
Select Targeted App. Choose the app that you want to associate a configuration policy with. Select from the list of Android Enterprise fully managed work profile apps that you've approved and synchronized with Intune. Select Permissions > Add. From the list, select the available app permissions > OK.
The following fixed the problem:
startActivity(Intent.createChooser(sendIntent, "title"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With