简体   繁体   中英

Chrome Custom tab links does not launch the app, but mobile chrome browser does

I'm trying to launch my android application through a browser link.

When I open the link through the chrome browser, it successfully shows the App Dialog Picker which shows the app available for the scheme like this.

app dialog picker

But when the link is opened through the Chrome Custom tab, it just redirects to the site without showing the App Dialog Picker .

I need it to launch the app or show the dialog picker when the link is opened from another app (like gmail) which opens the in-app browser and not just in the chrome browser.

here is the current intent-filter I have.

            <intent-filter>
                <data 
                    android:scheme="http" 
                    android:host="www.myapp.com" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />        
            </intent-filter>

If anyone could point out would be a great help. Thanks

So if ever anyone encounters the same problem, here's what I did. To launch your app with Chrome Custom Tabs browser, you need to make your scheme a non web-link format and make it into a custom scheme (example below). Because apparently, Chrome Custom tabs considers web link schemes as an ordinary link therefore launching it in the browser.

so from

            <intent-filter>
                <data 
                    android:scheme="http"
                    android:host="www.myapp.com" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE" />        
            </intent-filter>

change the scheme to a custom one, that way, your app's scheme will be the only one that gets handled by the browser. This is an example link with the scheme given below ~ myapp://myapp.app (note that this link is not clickable in android apps, but you can place it in the href of the html anchor tag of your website).

        <intent-filter>
            <data 
                android:scheme="myapp" 
                android:host="myapp.app" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />        
        </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