2

I am working on an android app and when a user clicks on a link and/or file, I want to give them the choice of choosing which app they want to use to open that link and/or file. At the moment it works the way it was intended to, but I am having trouble trying to let the user select a checkbox which lets them choose the default app to open that file with so they won't have to keep selecting it each time. I was thinking of having a checkbox in the dialog and then committing the value of it to the Shared prefs along with the app choice. After that, each time they click that file, the default app will be opened. In essence I am trying to get a dialog like this one, enter image description here

But I keep getting this one,

enter image description here

Here is the code:

Intent intent = new Intent(Intent.ACTION_VIEW).setDataAndType(uri, mimeChoice);
startActivity(Intent.createChooser(intent,getActivity().getString(R.string.open_with_title)));
user2351234
  • 965
  • 2
  • 12
  • 20
  • You usually don't have to create this dialog unless you want something very specific. The Android OS will take care of this depending on the Intent you've constructed. – Tamby Kojak Apr 05 '14 at 22:36

1 Answers1

0

like tambykojak point out, the "The Android OS will take care of this depending on the Intent you've constructed" and there´s no option for default app. But you will construct your own custom dialog by gettin the apps installed determined by the package: for example:

Facebook: "com.facebook.katana"; Whatsapp: "com.whatsapp"; Twitter: "com.twitter.android"; Google Playstore: "com.android.vending"; Chrome: "com.android.chrome" etc...

And saving the "default" option in preferences.

More info:

How to force Share Intent to open a specific app?

How to filter specific apps for ACTION_SEND intent (and set a different text for each app)

Community
  • 1
  • 1
Jorgesys
  • 124,308
  • 23
  • 334
  • 268