2

Context: I am developing an efficient open-source android launcher (view on GitHub). In its settings-activity is a button labeled Install apps that is supposed to take the user to a store of his choice (F-Droid or the PlayStore).


Currently, the button is only capable of opening the PlayStore. Here's the corresponding code (minimal reproducible example):

// in the install buttons on-click listener:

val storeIntent = Intent(
  Intent.ACTION_VIEW,
  Uri.parse("https://play.google.com/store/apps/")
)
startActivity(storeIntent) // go to the store

Other posts on StackOverflow have shown me to use market:// URIs (from this answer) in order to open any store using an intent (and automatically let the user decide which store they want to go to). This is functional (and used in the app at another point) but not very helpful here, as we want to open the stores main / start page.

A plain market:// URI does not select any app to be opened and URIs starting with market://details only are capable of searching ?q=, filtering stores by categories ?c= and of displaying app-details.


Is there an URI / Intent that can be used to take users to any store's main page (the system suggests capable market-apps)?

finnmglas
  • 1,626
  • 4
  • 22
  • 37
  • Related posts you may want to look at (that didn't solve my issue): [linking to android app-store details pages](https://stackoverflow.com/q/3239478/12787264), [opening playstore from an android application](https://stackoverflow.com/q/11753000/12787264) ... any help or clues are appreciated – finnmglas Oct 18 '20 at 22:46
  • any updates to your quest? – cregox Jul 05 '22 at 18:23

1 Answers1

1

Here's the corresponding code

Note that there is no requirement for the Play Store app to advertise an <intent-filter> matching this Intent structure. This Intent might launch a browser, if someday the Play Store removes that <intent-filter>. It also might crash with an ActivityNotFoundException, if the user does not have a suitable app (e.g., they are running a restricted profile and lack access to both the Play Store and a Web browser).

Is there an URI / Intent that can be used to take users to any store's main page (the system suggests capable market-apps)?

No, insofar as there is no requirement for any particular app store's app to advertise to other apps that they, indeed, are an app store.

You can try to use CATEGORY_APP_MARKET in a selector Intent try to pull in app stores:

    private fun launchGooglePlay() {
        val intent = Intent.makeMainSelectorActivity(
            Intent.ACTION_MAIN,
            Intent.CATEGORY_APP_MARKET
        )
        try {
            startActivity(intent)
        } catch (e: ActivityNotFoundException) {
            Log.e(tag, "launchGooglePlay()", e)
        }
    }

(from this gist)

However, based on a quick scan of the F-Droid manifest, I don't think that they will respond to this. If they don't, you could contribute a change to their project so that they will. However, whether Huawei's, Samsung's, or other app stores support this Intent approach is up to their developers.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thank you for the answer - you're right, the F-Droid android app does not respond to it. Improving their code is indeed an option, however not a very quick solution... I noticed how the `market://` URIs are received by both, F-Droid and Google Play... it seems those URIs can't be used to go to a store's start-screen / Main Activity though... seems a little odd to me (these URIs only link to app-details and search queries)... – finnmglas Oct 18 '20 at 23:13
  • I also tried empty search query-market URIs (`market://details?q=`) and other odd things to make it work... the empty search query with a view intent even took me to the f-droid main page, not for google play though... – finnmglas Oct 18 '20 at 23:14