5

I have defined an intent filter in order to launch my app from some kinds of URLs. The point is that it is launched for all the kinds of links, and I only want to be launched for a concrete host name. Here is my manifest:

    <activity
        android:name="com.imin.SplashActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:logo="@drawable/img_action_icon"
        android:screenOrientation="portrait"
        android:theme="@style/AppTeme.Fullscreen" >
        <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.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="imintheapp.com"
                android:pathPrefix="/events/get/"
                android:scheme="http" />
        </intent-filter>
    </activity>

I need to open my app ONLY in the following cases: http://imintheapp.com/events/get/xxxxxxxx where xxxxxxxx is an alphanumeric string.

What I am doing wrong? Regards,

Didac Perez Parera
  • 3,734
  • 3
  • 52
  • 87
  • It looks fine. Are you saying that from any link in any app regardless of domain, your app is an option to open the url? So, for example, in Chrome if you click a link to www.google.com, your app will either launch or be an option presented to the user? – Rich Nov 19 '13 at 01:40
  • Yes! that's it, any url opens the app, for instance www.google.com. – Didac Perez Parera Nov 20 '13 at 13:59
  • I've just tested this and it works as expected, i.e. only Intent URIs of the form http://imintheapp.com/events/get/xxxxxxxx resolve to your activity. What version of Android are you working with? – Reuben Scratton Nov 25 '13 at 09:50

3 Answers3

3

Add this code in Menifest.xml

           <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:host="www.parag-chauhan.com"
                    android:path="/test"
                    android:scheme="http" />
            </intent-filter>

For test create another project and run below code

Intent i = new Intent(Intent.ACTION_VIEW , Uri.parse("http://www.parag-chauhan.com/test"));
startActivity(i);

You can also pass parameter in link for more info http://paragchauhan2010.blogspot.com/2013/03/make-link-in-android-browser-start-up.html

Parag Chauhan
  • 35,760
  • 13
  • 86
  • 95
  • 1
    @DídacPérez it is working fine for me .Did you check call url using Intent ? – Parag Chauhan Nov 30 '13 at 13:56
  • Not in my device. If I choose 'don't ask again', links like www.google.com also launch my app... it has no sense. – Didac Perez Parera Nov 30 '13 at 18:45
  • Hi Parag .Can you please look into this.I tried the same but nothing happens on 5.1 (Lollipop) . I want any link from browser shared into my app and I want the title of that post. Eg: gmail. I really appreciate your time and help http://stackoverflow.com/questions/32218607/get-your-app-when-share-is-clicked-on-chrome-url-in-android-in-5-1-lollipop . Thanks – jason Aug 27 '15 at 00:04
  • @jason Can you plz explain little bit more? – Parag Chauhan Aug 27 '15 at 06:38
  • @ParagChauhan Thanks for your response . I have added the links above to my manifest and it opens the app only if I click on any link but not when I try to share my link from chrome browser in android. I don't know why that happens . I really appreciate your help . Added new Q http://stackoverflow.com/questions/32239039/my-app-is-not-displayed-when-i-click-on-share-on-browser-in-lollipop-5-1 Thanks. – jason Aug 27 '15 at 20:53
  • it doesnot work even though I tried it with the files not worked – Ahmad Arslan Aug 28 '19 at 13:01
1

Try this

<data
            android:host="imintheapp.com"
            android:path="/events/get/"
            android:scheme="http" />
MAkS
  • 751
  • 3
  • 10
  • 19
1

I think you should look at the intent-filter element of your Mainfest file. Specifically, take a look at the documentation for the data sub-element.

Read those docs again.

I also suggest you to read the 2nd ans of this Que.

Community
  • 1
  • 1
Jatin Malwal
  • 5,133
  • 2
  • 23
  • 26