1

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 .

1 Answer 1

3

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.