Erik Sapir
Erik Sapir

Reputation: 24717

Android - url scheme does not work and application does not open

I want to run my app from a custom url. I added the following to the AndroidManifest:

<activity android:name=".app.RunFromUrlActivity"
            android:launchMode="singleInstance">
            <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>

However, when i try to go to myapp://data the browser simply searches fot that string instead of running my Activity.

What am i doing wrong?

Upvotes: 4

Views: 2473

Answers (1)

WindyB
WindyB

Reputation: 786

Try something like this for "data":

<data
    android:host="com.yourpackage.yourotherstuff.TheActivity"
    android:scheme="yourscheme" />

Here's one that works for my app:

<activity android:name=".BrowserActivity" >
    <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:host="com.mypackage.otherstuff.BrowserActivity"
            android:scheme="myapp" />
    </intent-filter>
</activity>

This makes my activity accessible via myapp://com.mypackage.otherstuff.BrowserActivity.

Upvotes: 1

Related Questions