简体   繁体   English

URL更改时获取Webview的URL

[英]get URL of webview when URL changes

i use webview to make paypal payment on my android. 我使用webview在我的android上进行贝宝付款。 payment is actually happening at server, i just upload the url into my webview. 付款实际上是在服务器上发生的,我只是将URL上传到我的webview中。 when payment is complete i redirect browser to a page. 付款完成后,我将浏览器重定向到页面。 this is working fine. 这很好。 but what i want is when page is redirected to this success page i should be able to start new activity. 但是我想要的是当页面重定向到此成功页面时,我应该能够启动新活动。 i am using below method but it is not able to get success URL. 我正在使用以下方法,但无法获取成功URL。

_webView.setWebViewClient(new WebViewClient() 
            {
                public boolean shouldOverrideUrlLoading(WebView view, String url) 
                {
                    //Our servlet only uses one url for both success or failure
                    if (url.trim().equals("http://www.MyDomain.com/MobilePaypal/ReturnPage.aspx")) 
                    { 
                         Intent iPrintReciept = new Intent(getApplicationContext(), PrintReciept.class) ;
                        //Intent iPrintReciept = new Intent(Payment.this,PrintReciept.class);
                        startActivity(iPrintReciept);

                    } 
                    return false; 
                }
            });

If your working class is an activity then use like below 如果您的工人阶级是一项活动,则使用如下所示

Intent iPrintReciept = new Intent(yourActivityName.this, PrintReciept.class);

If your working class is not activity the use 如果您的工人阶级没有活动,则使用

Intent iPrintReciept = new Intent(context,PrintReciept.class);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM