shouldOverrideUrlLoading只获得呼吁某些网页 [英] shouldOverrideUrlLoading gets called ONLY for SOME webpages

查看:510
本文介绍了shouldOverrideUrlLoading只获得呼吁某些网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是个性化的多个客户端应用程序的方法shouldOverrideUrlLoading。每个客户机都有它自己的网页时要被加载到web视图。我的问题是这样的:应用程序可以完美的客户端A和他的网页,但不会对客户'S B网页(这是不以任何方式与客户端的一个相关的)。所不同的,因为我测试过,是在被加载的内容中访问到的WebView链接客户'S B的情况下,shoulOverrideUrlLoading不工作(不会被调用)和客户端是一个网页完美。另一件事是,客户'S B网页并不能在一些Android的版本只工作,如2.1或2.3.6,但它工作正常2.3.3,2.3.5,4.0.2或4.0.3。

因此​​,这是有点儿奇怪。如果你碰巧知道任何事情,请大家帮忙!谢谢!)

编辑:我注意到,当网页不加载通过JavaScript请求链接shouldOverrideLoading不叫,它工作时不使用的JavaScript!但是当我设置webview.setJavaScriptEnabled(假),它的工作原理!我真的需要JavaScript的我的应用程序启用导致网页通常用于装载之外其他的东西的JavaScript,所以我不能禁用它,只是因为shouldOverrideUrlLoading不会被调用!

编辑2:更确切的说:

这一件作品和shouldOverrideUrlLoading被调用:

 < p =的onclicklocation.href ='linkHere'>
        NEWLINK
        <跨度类=图标,箭头>< / SPAN>
&所述; / P>

这一个不工作,shouldOverrideUrlLoading不会被调用:

 <一类=链接继承的href =linkHere>
        NEWLINK
        <跨度类=图标,箭头>< / SPAN>
&所述; / A>


解决方案

解决方案 shouldOverrideUrlLoading 不叫

 公共无效onPageStarted(的WebView视图,字符串URL,位图图标){        如果(url.contains(成功)){
            意向意图=新意图(WebviewActivity.this,OrderConfirmActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(意向);
        }其他{
            super.onPageStarted(查看,网址,图标);
        }
    }

I'm using the method shouldOverrideUrlLoading for an app that is personalised for multiple clients. Each client has it's own webpage that wants to be loaded into the webview. My problem is this: the app works perfect for client A and his webpage, but doesn't for client's B webpage (which isn't related with client A in any way). The difference, as I've tested, is that in client's B situation for the links that are accessed within the loaded content into the webview, shoulOverrideUrlLoading isn't working (NEVER gets called) and for client's A webpage works perfectly. Another thing is that client's B webpage doesn't work only on some Android versions, like 2.1 or 2.3.6 but it works fine on 2.3.3, 2.3.5, 4.0.2 or 4.0.3.

So this is kinda odd. If you happen to know anything, please help! Thanks!:)

EDIT: I noticed that shouldOverrideLoading isn't called when the webpage does NOT load the requested link through javascript and it works when javascript isn't used!!! but when I set webview.setJavaScriptEnabled(false) it works!!! I really need javascript to be enabled for my app cause the webpages usually use javascript for other things besides loading so I cannot disable it just because shouldOverrideUrlLoading doesn't get called!

EDIT 2: To be more exact:

This one works and shouldOverrideUrlLoading gets called:

<p onclick="location.href='linkHere'">
        NewLink
        <span class="icon-arrow"></span>
</p>

This one does NOT work and shouldOverrideUrlLoading does NOT get called:

<a class="link-inherit" href="linkHere">
        NewLink
        <span class="icon-arrow"></span>
</a>

解决方案

Solution for shouldOverrideUrlLoading not called

public void onPageStarted(WebView view, String url, Bitmap favicon) {

        if (url.contains("success")) {
            Intent intent = new Intent(WebviewActivity.this, OrderConfirmActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
        } else {
            super.onPageStarted(view, url, favicon);
        }
    }

这篇关于shouldOverrideUrlLoading只获得呼吁某些网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆