4

I want to launch my app from a custom URL scheme. I checked the deep links section on dev android and here is a snippet of my code. This doesnt seem to fire though with a URL that looks like : myApp://?host=myhost.com

Manifest :

<intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="myApp" /> </intent-filter> 

In the activity which is my main activity, i have :

Intent intent = getIntent(); Uri uri = intent.getData(); if (uri != null) { String host = uri.getQueryParameter("host"); } 

The app does not launch when i have email that has the url as a hyperlink. Also, what would be a good way to test this ?

3 Answers 3

2

Try this, edit your IntentFilter

<intent-filter> <action android:name="android.intent.action.VIEW"></action> <category android:name="android.intent.category.DEFAULT"></category> <category android:name="android.intent.category.BROWSABLE"></category> <data android:host="www.youtube.com" android:scheme="http"></data> </intent-filter> 

EDIT

<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"></action> <category android:name="android.intent.category.DEFAULT"></category> <category android:name="android.intent.category.BROWSABLE"></category> <data android:host="www.youtube.com" android:scheme="http"></data> </intent-filter> 
Sign up to request clarification or add additional context in comments.

4 Comments

My action is MAIN which is the entry pt. into the app. Wouldnt it work with MAIN ?
Okay I've edited my question. This is how you can have two separate IntentFilters.
Cool thanks but i found that you can combine them into a single intent filter and order them.
I am able to successfully launch apps with URL style calls, however, its launching the app from within my own app, not in a new window. What intent can I use to force the app to a new window?
1

The browser converts the scheme to lowercase, so you need to change the data tag to

<data android:scheme="myapp"/> 

Comments

0

k it looks like ACTION_VIEW is a must to support custom URI schemes. I can add VIEW and MAIN though which gets it to work.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.