2

Google suggests the way to link to the Google Play Store is:

  • market://details?id=<package_name> if you are in an application, and
  • http://play.google.com/store/apps/details?id=<package_name> if you are on a webpage.

When we followed this strategy, we got a toast of "No such app found", even though the Google Play Store had the app we were looking for.

This turned out to be caused by the competition of two market handlers: F-droid (Open source marketplace) and Google Play Store. I found there were multiple by looking at the package manager for the intent resolvers.

I only ever want apps in the Google Play Store to be linked to by my app. Is there a way to force that app to respond to my market://[...] link?

Other strategies suggest attempting one approach, and if that fails, trying the http://[...] link. (The linked solution failed for me, as no exception was thrown.)

What will go wrong if I always link via the http:// method? I.e., skip the market:// link, and use http:// directly in the app. Will this decision come back to haunt me later?

Community
  • 1
  • 1
Atreys
  • 3,741
  • 1
  • 17
  • 27
  • If F-Droid responds to `market://`, users should get a chooser when your `market://` links are clicked upon, unless they specifically chose F-Droid as the default app for that `Intent` structure. Are you saying that you can reproduce behavior where this does occur, and even though there is no default (or the Play Store is default), that `market://` links go to F-Droid? – CommonsWare Jun 20 '14 at 22:42
  • 1
    I suspect that F-Droid was marked as Default. It was on someone else's device. Getting them to remove F-Droid 'fixed' the problem, but I wanted a more permanent solution to the problem, as I'm not linking to open source apps, I'm linking to Google play store ones. – Atreys Jun 20 '14 at 22:58

1 Answers1

2

I'm not linking to open source apps, I'm linking to Google play store ones

No, you are trying to open a Uri with an ACTION_VIEW Intent. In principle, the user is welcome to handle that request with anything they want, just as they can open a PDF with whatever app they want. This is one of the few places in Android where I think that it is justified to try to force the issue and steer the user to a particular app and away from whatever they might normally choose.

I only ever want apps in the Google Play Store to be linked to by my app. Is there a way to force that app to respond to my market://[...] link?

If you are the one calling startActivity() for this Uri, you could wrap the Intent in Intent.createChooser(). This would force the chooser dialog to appear, avoiding the default, if there is more than one activity matching the Intent. This is the safest and most stable approach, as it does not depend on any details of the Play Store itself.

You could call setComponent() on the Intent and provide a ComponentName that theoretically points to the desired activity. That's one Google refactoring away from breaking.

You can try to see if setPackage() will limit Intent resolution to your desired app. Once again, if Google decides to switch to a different package as its entry point to the Play Store, you would have to adapt. And I'm not sure if setPackage() is honored in this scenario.

Other strategies suggest attempting one approach, and if that fails, trying the http://[...] link. (The linked solution failed for me, as no exception was thrown.)

Yes, because your problem isn't that there's no match, but that there are multiple matches, and another choice was made instead of the one that you want.

What will go wrong if I always link via the http:// method? I.e., skip the market:// link, and use http:// directly in the app.

This doesn't really solve your problem, insofar as there are other apps that handle that Intent, like Web browsers.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491