Search code examples
javaandroideclipseandroid-intentintentfilter

Launching Activity via Intent Viewer and browser address bar - nothing happens - only when clicking link


I'm attempting to launch an activity from the browser (which simply displays a warning icon) when a user accesses a website however when I add the intent filter to my AndroidManifest.xml the application never launches the new activity upon loading the URL.

The only way it will load is if it's a link to the url (such as in an email) instead of when the user actually pulls up www.playboy.com

Any suggestions?

  • Amani

MANIFEST

<activity
        android:name="com.app.Warning"
        android:label="@string/app_name" >
        <intent-filter>  
<action android:name="android.intent.action.VIEW"></action>  
<category android:name="android.intent.category.DEFAULT"></category>  
<category android:name="android.intent.category.BROWSABLE"></category>  
<data android:host="playboy.com" android:scheme="http"></data>  
</intent-filter> 
    </activity>

Solution

  • When in doubt, copy Google. The Play Store and YouTube apps both use some sort of path specification in their intent-filters. Try something like pathPrefix="/".

    The manifest for Google Play Store includes the line:

    <data android:scheme="http" android:host="market.android.com" android:pathPrefix="/" />