监控网络中的Andr​​oid编程浏览器? [英] monitor web browser programmatically in Android?

查看:104
本文介绍了监控网络中的Andr​​oid编程浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这里有一个棘手的问题。我需要用户进行支付银行(即巴克莱)在英国。要做到这一点,我有一个HTTPS URL,我添加参数(如金额支付,订单编号等)的URL,启动该HTTP连接为Intent.ActionView,这将用户重定向到浏览器,在那里他可以输入自己的信用卡详细信息,银行的网页,并支付给我们的帐户成功。到目前为止好?

在code我用的是下面(我改变值隐私的原因),现在的问题是,我需要找回的应用程序,当用户完成/失败/取消付款。 Barclaycardautomatically重定向到一个特定的URL时,付款成功,另外一个,如果它失败了。难道就没有办法知道什么时候巴克莱支付已经成功,这样那我就回去了android应用程序以某种方式吗?

 按钮cardbutton =(按钮)findViewById(R.id.card_button);
cardbutton.setOnClickListener(新View.OnClickListener()
{
    @覆盖
    公共无效的onClick(查看arg0中)
    {
        字符串preHashString =新的String();
        字符串proHashString =新的String();
        字符串SHAPassPhrase =新的String();

        SHAPassPhrase =GSvTh£h70ZkHdAq9b; //测试环境

        preHashString = preHashString +金额=+将String.valueOf((INT)(order.getPaymentAmount()* 100.00))+ SHAPassPhrase;
        preHashString = preHashString +BGCOLOR = CCCCCC+ SHAPassPhrase;
        preHashString = preHashString +CN =+ user.getString(姓名)+ SHAPassPhrase;
        preHashString = preHashString +汇率= GBP+ SHAPassPhrase;
        preHashString = preHashString +LANGUAGE = EN_US+ SHAPassPhrase;
        preHashString = preHashString +ORDERID =+ order.getOrderId()+ SHAPassPhrase;

        尝试
        {
            proHashString = SHA1(preHashString);
        }
        赶上(抛出:NoSuchAlgorithmException E)
        {
            e.printStackTrace();
        }
        赶上(UnsupportedEncodingException E)
        {
            e.printStackTrace();
        }

        字符串的redirectUrl =htt​​ps://mdepayments.epdq.co.uk/ncol/test/orderstandard.asp;

        的redirectUrl + = +将String.valueOf((INT)(order.getPaymentAmount()* 100))金额=?;
        的redirectUrl + =&放大器; CN =+ user.getString(姓名);
        的redirectUrl + =&放大器;货币= GBP;
        的redirectUrl + =&放大器; LANGUAGE = EN_US;
        的redirectUrl + =与& ORDERID =+ order.getOrderId();
        的redirectUrl + =&放大器; SHASIGN =+ proHashString;

        意图I =新的意图(Intent.ACTION_VIEW,Uri.parse(的redirectUrl));
        startActivity(ⅰ);
    }
});
 

解决方案

您可以有自己的地方web视图你的应用程序里面,有一些做得/关闭按钮的地方。然后你可以跟踪所有的网址让你的WebView开放不要你的东西accordingly..User会留在你的应用程序always..that解决你的目的。

有关跟踪的所有URL您的WebView里面,你需要注册一个WebViewClient和ovveride以下功能

 公共布尔shouldOverrideUrlLoading(web视图查看,字符串URL)
 

看一看的WebView这里和的 WebViewClient这里

I've got a tricky question here. I need users to make a payment to a bank (namely Barclaycard) in UK. To do so, I have a https URL , I add the parameters (such as amount to pay, order reference, etc) to the URL, start this http connection as an Intent.ActionView, which will redirect the user to the browser where he can enter his credit card details on the bank's webpage and make the payment to our account successfully. So far so good ?

The code I use is below (I changed values for privacy reasons) The problem is, I need to get back to the app when the user has completed/failed/cancelled the payment. Barclaycardautomatically redirects to a particular URL when the payment has succeeded, another one if it failed. Is there no way of knowing when Barclaycard payment has succeeded so that then I would go back to the android app somehow ?

Button cardbutton = (Button) findViewById(R.id.card_button);
cardbutton.setOnClickListener(new View.OnClickListener()
{
    @Override
    public void onClick(View arg0)
    {
        String preHashString = new String();
        String proHashString = new String();
        String SHAPassPhrase = new String();

        SHAPassPhrase = "GSvTh£h70ZkHdAq9b"; // FOR TEST ENVIRONMENT

        preHashString = preHashString + "AMOUNT=" + String.valueOf((int) (order.getPaymentAmount() * 100.00)) + SHAPassPhrase;
        preHashString = preHashString + "BGCOLOR=cccccc" + SHAPassPhrase;
        preHashString = preHashString + "CN=" + user.getString("name") + SHAPassPhrase;
        preHashString = preHashString + "CURRENCY=GBP" + SHAPassPhrase;
        preHashString = preHashString + "LANGUAGE=en_US" + SHAPassPhrase;
        preHashString = preHashString + "ORDERID=" + order.getOrderId() + SHAPassPhrase;

        try
        {
            proHashString = SHA1(preHashString);
        }
        catch (NoSuchAlgorithmException e)
        {
            e.printStackTrace();
        }
        catch (UnsupportedEncodingException e)
        {
            e.printStackTrace();
        }

        String redirecturl = "https://mdepayments.epdq.co.uk/ncol/test/orderstandard.asp";

        redirecturl += "?AMOUNT=" + String.valueOf((int) (order.getPaymentAmount() * 100));
        redirecturl += "&CN=" + user.getString("name");
        redirecturl += "&CURRENCY=GBP";
        redirecturl += "&LANGUAGE=en_US";
        redirecturl += "&ORDERID=" + order.getOrderId();
        redirecturl += "&SHASIGN=" + proHashString;

        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(redirecturl));
        startActivity(i);
    }
});

解决方案

You can have your own Webview in place inside your app, with some done / close button somewhere.. Then you can track all urls getting open in your WebView and do your stuff accordingly..User will stay in your app always..that solves your purpose..

For tracking all urls inside your WebView you need to register one WebViewClient and ovveride below function

public boolean shouldOverrideUrlLoading (WebView view, String url)

Have a look at WebView here and WebViewClient here

这篇关于监控网络中的Andr​​oid编程浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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