Web界面代码
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="liyue://888.com/">打开app</a><br/>
</body>
</html>
看Android端配置文件代码
<!--过渡界面-->
<activity
android:name=".guidemodule.activity.SplashActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!--这里一定要写两个过滤器,不然你的app图标就会找不到-->
<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="888.com"
android:scheme="liyue" />
</intent-filter>
</activity>
好了,通过上边的方式就可以打开自己App了.
如何获取web链接传递过来的参数呢
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="liyue://888.com/?arg=0&data=1">打开app</a><br/>
</body>
</html>
如果你是通过webchrome打开的
Uri uri = getIntent().getData();
String test1= uri.getQueryParameter("arg");
String test2= uri.getQueryParameter("data");
如果你是webview打开的
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Uri uri=Uri.parse(url);
if(uri.getScheme().equals("liyue")&&uri.getHost().equals("888.com)){
String arg0=uri.getQueryParameter("arg");
String arg1=uri.getQueryParameter("data");
}else{
view.loadUrl(url);
}
return true;
}
});
有什么不懂得欢迎留言给我,或者加我个人微信公众号