1

I want to open my app with a link. The link I want to use, is the link to the google play store. I tried it, but my app doesn't start. Is it possible to do this?

In my manifest I do the following:

<activity android:name="myApp">
<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="http" android:host="play.google.com" 
            android:path="/store/apps/details?id=myApp" />
        <data android:scheme="https" android:host="play.google.com" 
            android:path="/store/apps/details?id=myApp" />
    </intent-filter>
</activity>

I tried it with pathPrefix, too.

best regards

BHuelse
  • 2,889
  • 3
  • 30
  • 41
  • Do you want to intercept the link `play.google.com/store/apps/details?id=myApp` and open your app instead of redirecting to play store? – Alex Kombo Jul 29 '15 at 14:29
  • Yes, when my app is installed I want to get a selection dialog. – BHuelse Jul 30 '15 at 08:09
  • I think it doesn't wok with the google play link. I have solved it by using an extra website. So I get my selection dialog and can open my app. On the site I link redirect to google play. – BHuelse Aug 03 '15 at 12:35
  • Hi did you get a solution to this i am stuck with same problem. If you have found a solution you can answer it on my question i will suerly upvote your answer http://stackoverflow.com/questions/35417950/how-to-open-my-application-when-app-link-is-clicked – Android Feb 24 '16 at 18:30

3 Answers3

2

The best way to open app's link to the Google Play.

String appPackageName = getPackageName();
            try {
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
            } catch (android.content.ActivityNotFoundException anfe) {
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
            }

If you are using Fragment then you can get packageName so:

String appPackageName = getActivity().getPackageName();

In Adapter you can get so:

String appPackageName = context.getPackageName();
Yakub
  • 71
  • 12
  • We use a try/catch block here because an Exception will be thrown if the Play Store is not installed on the target device. – Yakub Jun 25 '19 at 08:11
0

don't know if its late or not but this one might work for you

<intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE"/>
                <data android:scheme="http" android:host="some.host.com" android:pathPrefix="/store/apps/details" />
</intent-filter>
Masoud Dadashi
  • 1,044
  • 10
  • 11
-2

USE INTENT:

String url = "https://play.google.com/store/apps/details?id=org.example.omri.saharplus";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

and in MANIFEST

<uses-permission android:name="android.permission.INTERNET" />