简体   繁体   中英

Android intent not working to make app launcheable from browser

I'm trying to achieve this using the following code:

    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
         <intent-filter>
            <data android:scheme="ttest" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

Clicking 'debug' on Eclipse will launch my app correctly. But going to the browser and typing 'ttest://foo' won't launch the app as expected. What's wrong?

I did some tests on an HTC Sensation running ICS, a Samsung running 2.3.3, and a 4.0.3 emulator. I couldn't get any URL intent handling to work on the HTC, but had no trouble with the Samsung or the emulator. Any chance you're using an HTC phone? Apparently HTCs have a problem with this: Standard intent URI broken?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM