3

i'm trying to provide the user with an option to find something in google play. i'm trying to use the Intent.createChooser but the chooser is not displayed, the market is just opened immediately without displaying the chooser.

i searched around and the closest thing was to declare the file type but i wish to open the market so this seems not relevant for me.

anyone has an idea?

        val marketIntent = Intent(Intent.ACTION_VIEW)
        marketIntent.data = Uri.parse("market://search?q=${file.extension}")

        if(marketIntent.resolveActivity(packageManager)!=null) {
            callback?.onSuccess(null)
            startActivity(Intent.createChooser(marketIntent, "look for app in google play?").)

        }
Shay Vilk
  • 33
  • 5

1 Answers1

3

Perhaps there is only one activity on the device that handles market schemes for ACTION_VIEW. You only get the chooser if there are 2+ activities that match your Intent.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • if this is true then it's not good for me... i do not want to trigger the move directly but to show the user the option to search for relevant apps on the play store. – Shay Vilk May 03 '18 at 22:09
  • @ShayVilk: Only start the activity if the user, in your app, indicates that they want to search for relevant apps. – CommonsWare May 03 '18 at 22:12
  • it seems this is correct. i ended up checking if the file type has an intent that handle it, if not i display a message asking if you wish to search the Market. – Shay Vilk May 06 '18 at 16:12