sulinly 2018-02-03 06:05 采纳率: 50%
浏览 12169
已结题

求助大神,如何阻止打开淘宝网站时自动打开淘宝app

现在淘宝网站貌似升级了,安卓开发时,用webview打开淘宝网站时会自动打开掏宝app。(其他浏览器也是这样)。如何阻止打开淘宝网站时自动打开淘宝app。
下面是webview打开http://h5.m.taobao.com/awp/core/detail.htm?id=563621033487 时的日志:
02-01 18:37:16.280 24675-24792/com.sugem.myapplication D/NetworkSecurityConfig: No Network Security Config specified, using platform default
02-01 18:37:16.664 24675-24675/com.sugem.myapplication W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 24675
02-01 18:37:16.678 24675-24675/com.sugem.myapplication I/chromium: [INFO:CONSOLE(2)] "The key "viewport-fit" is not recognized and ignored.", source: http://h5.m.taobao.com/awp/core/detail.htm?id=563621033487 (2)
02-01 18:37:17.147 24675-24746/com.sugem.myapplication W/WebKit: A Parser-blocking, cross-origin script, http://g.alicdn.com/mtb/lib-smartbanner-plus-loader/smartbanner-loader.js?t=15174814, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity. See https://www.chromestatus.com/feature/5718547946799104 for more details.
02-01 18:37:17.148 24675-24675/com.sugem.myapplication I/chromium: [INFO:CONSOLE(5)] "A Parser-blocking, cross-origin script, http://g.alicdn.com/mtb/lib-smartbanner-plus-loader/smartbanner-loader.js?t=15174814, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity. See https://www.chromestatus.com/feature/5718547946799104 for more details.", source: http://h5.m.taobao.com/awp/core/detail.htm?id=563621033487 (5)
02-01 18:37:18.049 24675-24675/com.sugem.myapplication I/chromium: [INFO:CONSOLE(98)] "[object Object]", source: webpack:///./src/js/stores/AppStores.js? (98)
02-01 18:37:18.165 24675-24675/com.sugem.myapplication I/chromium: [INFO:CONSOLE(5)] "warning: This interface is deprecated, please use goldlog.sendPV instead! API: http://log.alibaba-inc.com/log/info.htm?type=2277&id=31", source: http://g.alicdn.com/alilog/??s/8.0.1/plugin/aplus_client.js,aplus_cplugin/0.2.12/toolkit.js,aplus_cplugin/0.2.12/monitor.js,s/8.0.1/aplus_wap.js,aplus_cplugin/0.2.12/aol.js,s/8.0.1/plugin/aplus_spmact.js?v=20180130174216 (5)
02-01 18:37:19.535 24675-24675/com.sugem.myapplication I/chromium: [INFO:CONSOLE(8)] "The deviceorientation event is deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.", source: http://aeu.alicdn.com/js/cj/106.js (8)
02-01 18:37:19.552 24675-24675/com.sugem.myapplication D/SensorManager: +++(enableSensor)+++: type= 15,rateUs= 16666,package= com.sugem.myapplication,handle= 1600610674,maxBatchReportLatencyUs= 0

  • 写回答

3条回答

  • 命运的转折点 2018-02-03 07:14
    关注
     URL 语法
    
    
    URL由三部分组成:资源类型、存放资源的主机域名、资源文件名。
    
    对淘宝的自定义协议进行处理
    URL的一般语法格式为:
    
    (带方括号[]的为可选项):
    
    protocol :// hostname[:port] / path / [;parameters][?query]#fragment 
      public static class CommonWebViewClient extends WebViewClient {
    
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                Log.d("leo", "[webViewUrl]" + url);
                if (url.startsWith("tel")) {// 机构电话
                    Intent intent = new Intent(Intent.ACTION_DIAL);
                    intent.setData(Uri.parse(url));
                    view.getContext().startActivity(intent);
                    return true;
                }
                Uri uri = Uri.parse(url);
                if ("baonajia".equals(uri.getScheme())) {
                    if ("organization".equals(uri.getHost())) {// 课程详情跳转到机构详情
                        Organization organization = new Organization();
                        organization.setId(uri.getQueryParameter("organization_id"));
                        organization.setName(uri.getQueryParameter("organization_name"));
                        Intent intent = new Intent(view.getContext(), OrganizationDetailActivity.class);
                        intent.putExtra(Const.EXTRA_ORG, organization);
                        view.getContext().startActivity(intent);
                    } else if ("course".equals(uri.getHost())) {// 机构详情跳转到课程详情
                        new CourseTask(view, uri.getQueryParameter("course_id")).execute();
                    } else if ("school".equals(uri.getHost())) {// 机构详情跳转到校区列表
                        String orgId = uri.getQueryParameter("organization_id");
                        Intent intent = new Intent(view.getContext(), SchoolListActivity.class);
                        intent.putExtra(Const.EXTRA_ORG_ID, orgId);
                        view.getContext().startActivity(intent);
                    } else if ("album".equals(uri.getHost())) {// 机构详情跳转到相册列表
                        String orgId = uri.getQueryParameter("organization_id");
                        Intent intent = new Intent(view.getContext(), PhotoAlbumListActivity.class);
                        intent.putExtra(Const.EXTRA_ORG_ID, orgId);
                        view.getContext().startActivity(intent);
                    }
    
                    return true;
                } else {
                    view.loadUrl(url);
                    return true;
                }
            }
    
            @Override
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                Log.e(TAG,
                        String.format("errorCode: %s, description: %s, when open: %s", errorCode, description, failingUrl));
                view.loadUrl(URLCenter.getError());
            }
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题