I want my intent to be launched when the user goes to a certain url: for example, the android market does this with http://market.android.com/ urls. so does youtube. I want mine to do that too.
Android Respond To URL in Intent
Asked Answered
There's a great answer to this question at #2448713 –
Monde
There is a better answer to this question #1610073 –
Byelection
I did it! Using <intent-filter>
. Put the following into your manifest file:
<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.youtube.com" android:scheme="http" />
</intent-filter>
This works perfectly!
It doesnt work for me. Can you please give an example-Link that would open the Application. –
Local
I'd like to react to "www.youtube.com" but NOT to "www.youtube.com/fr/"... Any idea how I can do that? –
Berk
This works perfectly, thanks, but i also need to obtain the URL that was clicked to open the app. anyone can explain how to do this? –
Scorify
look #2959201 –
Mullis
This was the only thing that worked properly for me after browsing around for a long time, trying those random schemes such as "myapp://" but not being able to properly test them (or wasn't told how to test them). Put the above in, fire up the browser, search Youtube on Google, and any link will allow me to use my application to open it! –
Lowman
Not sure how this is working for the entire world. Just doesn't work on chrome and it always opens the link in browser until you place the "android:pathPrefix" element. The answer anyways doesn't have the category values as mentioned in the documentation. If it still doesn't work for someone, refer this please: https://mcmap.net/q/81883/-launching-custom-android-application-from-android-browser-chrome PS: struggled for days over this. –
Crossly
My problem is my link from email, or anyother resource needs to open first in browser then it redirected to the desired link, any solution how can i get that redirected app and open my application. –
Sontich
If you have problems with this solution is maybe because your final URL starts with the
host
pattern but is not exactly that. If this is the case, try adding: <data android:pathPattern=".*"/>
–
Trevethick remember that you also need to add the intent filter to the actual activity which will handle the incoming request –
Germinative
It is important to know that this only work if you open the link OUTSIDE of a browser , from the notes app, or a message from whatsapp, It is working on lollipop –
Liverwurst
You might need to allow different combinations of data in your intent filter to get it to work in different cases (http/
vs https/
, www.
vs no www.
, etc).
For example, I had to do the following for an app which would open when the user opened a link to Google Drive forms (www.docs.google.com/forms
)
Note that path prefix is optional.
<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" />
<data android:scheme="https" />
<data android:host="www.docs.google.com" />
<data android:host="docs.google.com" />
<data android:pathPrefix="/forms" />
</intent-filter>
© 2022 - 2024 — McMap. All rights reserved.