Searching for examples in other related questions i couldn't find one using both
<action android:name="android.intent.action.MAIN" />
and
<action android:name="android.intent.action.VIEW" />
(the latter seems to be mandatory for this kind of behaviour).
Anyway, it is possible to use both. This is my working example:
<activity
android:name="com.example.MainActivity"
android:label="@string/title_activity_main"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Light.NoTitleBar" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" />
</intent-filter>
</activity>
So, the following tags seem to do the trick:
android:exported="true"
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
This is the anchor i'm using from the web page:
<a href="myapp://somthing/anotherthing">Open the app!</a>
UPDATE: As developer82 mentioned in the comments, if you do this the app icon will dissapear and the user won't be able to open the app. To fix this, you'll need to create a new tag to put the <data>
along with default
, browsable
categories and view
action.
The <activity>
tag should look like this:
<activity
android:name="com.example.MainActivity"
android:label="@string/title_activity_main"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Light.NoTitleBar" android:exported="true">
<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:scheme="myapp" />
</intent-filter>
</activity>
Let me know if it helped!