Android 實現瀏覽器跳轉APP應用,網頁也可以跳轉APP

一、Android端如何操作

1、給Application中Activity添加跳轉鏈接路徑和相關權限

 <activity
            android:name=".activity.LoginActivity"
            android:exported="true">
            <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="login.app"
                    android:path="/openLogin"
                    android:scheme="alibaba" />
            </intent-filter>

        </activity>

scheme:判別啓動的App

host: 類似於端口,可用於分流,區分調取的功能

path:同上   ※沒有也可以喚起

注意: Activity配置中android:exported="true"這個外部是否可以調用一定要寫true,要不然會調用不成功,對於應用安全要求較高的一定要注意。

2、瀏覽器如何調起

<!-- 喚醒APP並跳轉至指定的path頁面 -->
<!--<a href="<scheme>://<path>?<params>=<value>">打開APP</a>-->
<a href="alibaba://openLogin/login.app">打開APP</a>
<!--或者都可以調用-->
<a href="alibaba://openLogin/login.app?userName=mayun">打開APP</a>

3、APP內部也可以調用起來

Intent intent = new Intent(
Intent.ACTION_VIEW,Uri.parse("alibaba://openLogin/login.app?userName=mayun"));
startActivity(intent);

4、ios同理

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章