简体   繁体   中英

Android http URL scheme is not working when I try to launch my application from a link on my website

I'm trying to achieve to have my application launched (or fire an open-in dialog) when a link pointing to http://example.com/123 on my website is clicked. In my AndroidManifest.xml I added the following activity to register my app for 'http' links with host 'example.com'. But it simply visits http://example.com/123 link and nothing happens other than that when I touch on the link.

<activity xmlns:android="http://schemas.android.com/apk/res/android"
          android:name=".TestActivity"
          android:label="myapplication">
<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="example.com" android:scheme="http" />
</intent-filter>
</activity> 

Also tried with

android:pathPattern = ".*"

or

android:pathPattern = "*"

but none of them work. I appreciate for any suggestions from now.

Try using pathPrefix instead of pathPattern.

<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="example.com"
        android:scheme="http"
        android:pathPrefix="/"/>
</intent-filter>

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