webview/h5跳转到app的指定activity
来源:互联网 发布:fm2016中文版for mac 编辑:程序博客网 时间:2024/06/04 23:23
开发时有时会碰到这样的需求,分享到第三方的h5页面,在点击操作的时候需要跳回APP的指定页面,这时只需要在该activity下面配置一下相应的scheme host等信息就可以了
App中配置:
<activity android:name=".xxActivity" android:launchMode="singleTask" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation" android:windowSoftInputMode="adjustPan"> <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="my" android:scheme="app" android:path="/my" /></intent-filter> </activity>h5或webview中配置:
<!DOCTYPE html><html><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <title></title> <script type="text/javascript" charset="utf-8"> function clickToApp(){ window.location.href="app://myapp/my?type=1"; } } </script> </head><body> <button onclick="clickToApp()">跳转到app指定页面</button> </body></html>
补充:
1.可以通过
Uri mData = this.getIntent().getData();if (mData != null) { String mType = mData.getQueryParameter("type");}
获取h5或者webview传递过来的值
2.如果在webview中没法正常跳转,可以配置webview如下:
// 选择跳转方式,true在本应用跳转,false通过浏览器跳转mWebView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { } @Override public boolean shouldOverrideUrlLoading(WebView view, String httpurl) { if (httpurl.startsWith("app:")) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(httpurl)); startActivity(intent); } return false; }});
阅读全文
0 0
- webview/h5跳转到app的指定activity
- H5跳转到APP指定页面
- Android通过uri跳转到APP指定的Activity
- android:scheme 通过uri跳转到APP应用指定Activity
- android Activity跳转到指定的Fragment
- Android activity跳转到另一个activity的指定fragment页面
- Android跳转到指定Activity
- 一个app跳转到另一个app的指定功能
- 从一个APP跳转到另一个APP的指定页面
- 网页启动App&网页跳转到App指定的页面
- WebView点击里面的按钮跳转到Activity
- 网页跳转到指定APP
- 在WebView和Activity中关闭到指定的页面
- 如何点击listView的item跳转到指定的Activity
- Android跳转其他app指定activity
- 通过手机浏览器跳转到指定的Activity
- 实现封装在安卓里的html5,跳转到指定activity
- Webview里JS跳转到Activity页面
- java.lang.OutOfMemoryError: GC overhead limit exceeded
- Flex 学习 Flex布局 弹性布局
- 折腾KALI简思
- 20017年11月(杭州班,广州班)高级采购管理师职业培训火热报名
- synchronized 解析使用
- webview/h5跳转到app的指定activity
- 表单自动定位到出错的位置处
- 长连接与短连接区别
- 10W年薪和30W+年薪的产品经理差距在哪?
- [BZOJ]3209: 花神的数论题 数位DP
- 打走企业级落地微服务的拦路虎:数据
- html_ionic选项卡切换
- 1、通过 BitNami 部署 RedMine
- matplotlib绘制多个子图——subplot