AlcubierreDrive
AlcubierreDrive

Reputation: 3664

Launch Intent from URL not working

I made a test Android app that I am trying to have launch when the browser hits the URL "blargh://yolo". But it is not working; instead the browser just does a google search.

It is a brand new project created by Eclipse/ADT; the only thing I've edited is the manifest, which is below:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.testurlscheming"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-permission android:name="android.permission.INTERNET"/>

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.testurlscheming.MainActivity"
            android:label="@string/app_name" >
            <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="blargh" />
            </intent-filter>

        </activity>
    </application>

Upvotes: 0

Views: 905

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007534

Some Web browsers, like the AOSP Browser app, treat the address bar differently than it does hyperlinks. Hyperlinks route through a check for who handles ACTION_VIEW for that URL. The address bar is assumed to be something relevant for the Browser app; if it does not recognize it, it conducts a search, just as if you had typed blargh yolo.

Do you know if it works from a redirect?

I would hope so. However, this may be browser-dependent. I would hope that browser makers follow the lead of Browser (and, over time, Chrome), but that's not guaranteed.

Upvotes: 1

Related Questions