android开发 友盟推送点击Notification使用WebView加载url同时会调用系统浏览器的问题
来源:互联网 发布:jquery.poshytip.js 编辑:程序博客网 时间:2024/06/03 11:16
项目中需要使用友盟推送操作一些数据,使用的是WebVeiw加载h5页面显示数据,刚开始使用UmengNotificationClickHandler的openUri方法做跳转加载页面数据的操作,不管在WebView怎么处理,
系统浏览器总是会被调用,研究了很久,最后采用自定义(服务端也要采用自定义方案)方法,系统浏览器才没有被调用:
public void launchApp(Context context, UMessage msg);public void openUrl(Context context, UMessage msg);public void openActivity(Context context, UMessage msg);public void dealWithCustomAction(Context context, UMessage msg);
这四个方法,分别对应于四种打开方式。其中,launchApp、openUrl、openActivity这三个方法已经由消息推送SDK完成,而dealWithCustomAction则只是一个空的方法。 若开发者需要处理自定义行为,则可以重写方法dealWithCustomAction();其中自定义行为的内容,存放在UMessage.custom中。
服务器把h5页面连接放在custom中传递给我,我在dealWithCustomAction方法中处理获取custom值,然后打开,这样就不会调用系统浏览器,刚开始找错了方向,一直以为是WebView设置问题…
UmengNotificationClickHandler umengNotificationClickHandler = new UmengNotificationClickHandler() { /** * 友盟推送通知点击事件的操作 使用此方法会导致WebView加载url的同事调用系统浏览器加载url, * @param context * @param uMessage */ /* @Override public void openUrl(Context context, UMessage uMessage) { super.openUrl(context, uMessage); ToastUtil.defaultToast(getApplicationContext(),"openUrl()"); Intent intent=new Intent(getApplicationContext(), LoadUriActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra("titleText","预约订单"); intent.putExtra("url",uMessage.url.toString()); shared.putString(Contants.WebUrl.OPEN_URI,uMessage.url); shared.putString(Contants.WebUrl.OPEN_TITLE,"预约订单"); ToastUtil.defaultToast(getApplicationContext(),uMessage.url); startActivity(intent); }*/ @Override public void dealWithCustomAction(Context context, UMessage uMessage) { super.dealWithCustomAction(context, uMessage); Intent intent = new Intent(getApplicationContext(), LoadUriActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shared.putString(Contants.WebUrl.OPEN_URI, uMessage.custom); shared.putString(Contants.WebUrl.OPEN_TITLE, "预约订单"); startActivity(intent); } }; PushAgent.getInstance(getApplicationContext()).setNotificationClickHandler(umengNotificationClickHandler);
此方法写在自定义Application类的OnCreate方法中
1 0
- android开发 友盟推送点击Notification使用WebView加载url同时会调用系统浏览器的问题
- 解决WebView加载URL跳转到系统浏览器的问题
- Android开发 activity里面的WebView加载js调用windows.location.reload()会弹出浏览器的解决方法
- Android使用WebView加载网页屏蔽系统浏览器的方法
- Android使用webview调用html时,点击会有淡蓝色的点击效果
- android WebView 应用内点击超链接不调用系统浏览器
- Android中webview中点击点解不调用系统浏览器解决
- 解决webview.loadUrl()会加载系统浏览器
- [Android] 使用 WebView 加载网页而不调用外部浏览器
- Android 通过点击浏览器或者内部WebView加载URL 唤起App
- Android强制使用WebView不调用系统或外部浏览器
- 如何在WebView中点击链接,使用自己的activity打开,不调用系统自带的浏览器
- WebView点击连接禁止跳到系统的浏览器及加载JS代码
- Android webview加载url
- Android WebView的使用(禁止超链接调用其他浏览器 设置滚动条 禁止横竖屏切换重新加载网页 )
- android webview 加载带视频的URL
- android webview loadurl弹出系统浏览器问题
- android webview loadurl弹出系统浏览器问题
- Maven系列二setting.xml 配置详解
- JavaScript函数浅析
- vs2008安装和编译curl库
- NSString 字符串处理:截取字符串、匹配字符串、分隔字符串
- poj 2240 Arbitrage
- android开发 友盟推送点击Notification使用WebView加载url同时会调用系统浏览器的问题
- Android 6.0 运行时权限处理
- 处理ViewPager嵌套ViewPager的滑动事件冲突
- openjudge 百练 熄灯问题
- hdu 1010
- Zephyr OS 系列博客索引目录
- 三篇线段树扫描线总结
- 网站收藏
- 3330顺序表应用6:有序顺序表查询