Mr.Smile填坑记——点击分享出去的网页,无法跳转自己的app

首先需要和web端的开发制定规则,也就是安卓中的 scheme
test://xxx?params=
scheme://host:port/path
一般host:port就是IP,端口号,正式的或者直接用域名就OK

scheme 这个就是我遇到的坑,必须小写,必须小写,必须小写,重要的话说3pathPattern 就是后面匹配的东西

在manifest中配置
 <activity android:name=".webapi.WebEntityActivity"
            android:configChanges="keyboardHidden|orientation"
            android:screenOrientation="portrait"
            android:launchMode="singleTask"
            android:windowSoftInputMode="stateAlwaysHidden">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:host="xxxx" android:scheme="test" />
            </intent-filter>
         </activity>

WebEntityActivityUri data = getIntent().getData();
String params = data.getQueryParameter("params");
params就是web端 返回给我们的数据,就是?后面的数据

再次说明 scheme必须小写,必须小写,必须小写
发布了22 篇原创文章 · 获赞 29 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/Keep_Holding_On/article/details/76208032