H5唤醒app并跳转到指定页面
2017-03-30 18:58
489 查看
在manifest文件中最开始启动的activity中添加:
<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="host" android:pathPrefix="/pathPrefix" android:scheme="scheme" /> </intent-filter> //注意host,pathPrefix,scheme都是自己自定义的,只要与h5页面调用的一致即可,如下所示
<activity android:name=".activitys.MainActivity" android:label="@string/app_name" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <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="host" android:pathPrefix="/pathPrefix" android:scheme="scheme" /> </intent-filter> </activity> 如果要跳转到指定的页面,在MainActivity的onCreate()中添加:
Intent intent = getIntent(); Uri uri = intent.getData(); if (uri != null) { String routeId = uri.getQueryParameter("pid"); Intent intent0 = new Intent(MainActivity.this, ZhidingActivity.class); startActivity(intent0); }
uri.getQueryParameter("pid");获取h5页面传递的参数,如果没有的话可以忽略<span style="font-size:18px;"><script>
注意一点,微信上对于app的唤醒有拦截,在浏览器中才可以起作用对于h5的代码如下:
function startAPP(){
window.location = "scheme://host/pathPrefix";
}
function downloadAPP(){
window.location = "apk下载地址";
}
</script>
<style type="text/css">
body{background:#D2D460;text-align:center;margin-top:10%}
div{width:100%;margin:0 auto;background:#fff;text-align:left;}
</style>
</head>
<body>
<?php
$var_name = $_GET["isappinstalled"];
if ($var_name=="1"){
echo '<img src=images/start.png alt=打开APP onclick=startAPP() ></img>';
}else if ($var_name=="0"){
echo '<img src=images/download.png alt=打开APP onclick=downloadAPP() ></img>';
}else{
echo '<img src=images/welcome.png alt=打开APP onclick=startAPP() ></img>';
}
?>
</body></span> 一定要注意:
window.location = "scheme://host/pathPrefix";scheme,host,pathPrefix一定要与android定义的一致
如果要传递参数的话:在后面拼接?pid=...即可
相关文章推荐
- h5页面唤醒app并跳转到指定页面
- Android实现深度链接(APP外带动态参数唤醒APP,并跳转指定页面,APP不论在不在运行都可以)
- H5跳转到APP指定页面
- H5页面唤醒App及App之间跳转
- h5页面唤醒APP指定页面并传参
- android锁屏状态下, 新消息唤醒屏幕,并跳转到指定页面
- 点击外部链接跳转App指定页面SingleTask模式
- 详解Android App卸载后跳转到指定的反馈页面的方法
- h5页面唤起app(iOS和Android),没有安装则跳转下载页面
- Android App跳转App以及App跳转指定App页面的实现
- iOS实现在webview页面内点击链接,跳转指定App
- ios俩个APP之间跳转、传值,以及直接跳转到指定app页面 或者 app 评价页面 的方法
- ios 应用中直接跳转到指定app页面 或者 app 评价页面 的方法
- iOS 从AppDelegate中跳转指定页面
- 基于应用宝实现微信h5页面中打开本地app,如果没有跳转下载页面的解决方案
- JS和安卓互相调用以及Scheme协议完成外部链接跳转app指定页面
- 奇酷360 手机中怎么跳转安全中心中指定包名App的权限管理页面
- ios 应用中直接跳转到指定app页面 或者 app 评价页面 的方法
- ios 应用中直接跳转到指定app页面 或者 app 评价页面 的方法
- H5页面app应用程序跳转探索