I am having an application with 4 different activities.
- activity 1 is for Live screen
- activity 2 is for Playback screen
I am implementating scenario to launch the activity from a url send to email client (Gmail).
User receive the email and it has 2 links :
- Link 1 is to open Live screen ( activity 1)
- Link 2 is to open Playback screen ( activity 2)
In my application manifest file, i created intent filter for activity 1 and activity 2.
<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" />
</intent-filter>
Issues
- when i use custom scheme (e.g "myapp" ) the link inside the Gmail is not clickable. I can only click the link if i add scheme as "http" . is it a drawback on android email clients? How to overcome this issue and use a clickable custom url.
- since i have added two intent filters inside my manifest file , when i click on the url link in the email, it opens a selector dialog to choose the application. Inside that , my application icon is shown 2 times. I want my application icon to be shown only once . and based on the link, it should open activity 1 or 2. it seems the icon appears number of times as per the intent filters given inside the manifest file. How can i overcome this issue
Unfortunately it is up to GMail whether or not it wants to play nice with custom URL schemes.
One commonly used solution is to link to a website that redirects the user to the custom URL scheme.
Only register one intent filter for each unique URI scheme that you want to intercept.
If your app needs to parse the data to determine where to go, then you can either put that logic in your main activity or create a special Activity for the sole purpose of parsing links and put the intent filter in that Activity's manifest entry.
If you are really using
<data android:scheme="http" />
, then your<data>
tags are simply too vague. You can make them more specific by adding host or path attributes so that your links only resolve to one of your intent filters instead of all of them.