android - 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;
}
解决方案
推荐阅读
- antlr4 - 使用 ANTLR4 解析具有多个 AND 和 OR 的规则?
- python - 图表中不显示点
- java - javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/http/HttpRequest 错误
- python-3.x - 是否可以在 Python 中绘制非常细的线?
- ios - iOS 上未显示基于本机的图标
- c++ - 无法使用 SSL/TLS 连接到 mongodb
- python - 如何将多个唯一元素附加到 Python 中的同一组列?
- arduino - 存储空指针数组
- compiler-errors - OCaml 中的递归函数返回未绑定值错误
- excel - 值未复制到正确的范围内