首页 > 解决方案 > Android 10:扫描新卡在 Google chrome 中不起作用

问题描述

我正在 webview 中集成 html 页面,并且我需要扫描信用卡。但是,在我的 android 设备版本 10 中,“扫描新卡”选项不可见。在 android 8 中,此选项可见,但持卡人姓名未显示。所以有人有同样的想法吗?下面是活动代码:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mWebView = findViewById(R.id.activity_main_webview);
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    mWebView.setWebViewClient(new MyWebViewClient());
    // REMOTE RESOURCE
     mWebView.loadUrl("https://hostedhtml/");
}

下面是html代码:

<form action="freedomofkeima://?ThisIsResponseSample" method="get">
            <label for="nameoncard">Name on Card</label> 
            <input autocomplete="cc-name" id="nameoncard" name="nameoncard" type="text"> 
            <label for="ccnumber">Credit Card Number</label> 
            <input autocomplete="cc-number" id="ccnumber" name="ccnumber" type="text">
            <label for="cc-exp-month">Expiration Month</label> 
            <input autocomplete="cc-exp-month" id="cc-exp-month" name="cc-exp-month" type="text"> 
            <label for="cc-exp-year">Expiration Year</label> 
            <input autocomplete="cc-exp-year" id="cc-exp-year" name="cc-exp-year" type="text"> 
            <input name="submit" type="submit" value="Submit">
</form>

MyWebClient 代码:

 @Override
 public boolean shouldOverrideUrlLoading(WebView view, String url) {
    String hostname;

    // YOUR HOSTNAME
    hostname = "example.com";

    Uri uri = Uri.parse(url);
    if (url.startsWith("file:") || uri.getHost() != null && uri.getHost().endsWith(hostname)) {
        return false;
    }
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    view.getContext().startActivity(intent);
    return true;
}

标签: androidwebviewandroid-webview

解决方案


推荐阅读