Reputation: 13
How can I create a custom protocol in Android?
I have tried this code:
<activity android:name=".MyActivity" android:label="@string/app_name">
<!-- open the app when a foo://www.example.com link is clicked -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="foo" />
</intent-filter>
Register this in Manifest file and call in browser like this foo://hello but it not open my app .
Upvotes: 1
Views: 2886
Reputation: 22527
I remember having similar problem a while back. Hope my solution will help you solve yours.
Add android:exported="true"
and move <data android:scheme="foo" />
on top.
<activity android:name=".MyActivity" android:label="@string/app_name"
android:exported="true">
<!-- open the app when a foo://www.example.com link is clicked -->
<intent-filter>
<data android:scheme="foo" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Upvotes: 3