Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Samsung devices automatically set default application for share Intent

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?

like image 525
fweigl Avatar asked Dec 15 '16 10:12

fweigl


People also ask

How do I manage default apps on my Android phone?

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.

How do I change the default permissions for Managed 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.

How many apps can be the default app on my Device?

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.

How do I associate a configuration policy to an Android app?

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.


1 Answers

The following fixed the problem:

startActivity(Intent.createChooser(sendIntent, "title"));
like image 51
fweigl Avatar answered Oct 06 '22 12:10

fweigl