** 升级 targetsdk 版本 29 后,我不得不将与 XWalkView 一起使用的应用程序转换为 Android Webview,因为该应用程序无法在 Android 10 上运行。现在我的应用程序打开但表单未提交。这就是支付屏幕打不开的原因。我在我的 PayActivity 中编写了下面的代码示例。**
myInterface = new WebAppInterface(PayActivity.this,getApplicationContext());
payWebView.addJavascriptInterface(myInterface, "NativePay");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}
WebSettings webSettings = payWebView.getSettings();
payWebView.getSettings().setDomStorageEnabled(true);
payWebView.getSettings().setAllowFileAccessFromFileURLs(true);
payWebView.getSettings().setAllowUniversalAccessFromFileURLs(true);
payWebView.getSettings().setAllowContentAccess(true);
payWebView.getSettings().setJavaScriptEnabled(true);
payWebView.getSettings().setDatabaseEnabled(true);
payWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
payWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading (WebView view, String url) {
return true;
}
public void onPageFinished(WebView view, String url) {
if (url.contains("/payment/online_odeme_basarili")) {
setResult(RESULT_OK);
finish();
} else if (url.contains("/payment/online_odeme_basarisiz")) {
setResult(RESULT_FIRST_USER);
finish();
}
}
});
payWebView.loadUrl("https://" + MainActivity.domainURL + "/payment/online_odeme/" + "1233 + "/" + "123" + "/" + "01", null);
构建.gradle
compileSdkVersion 29
buildToolsVersion '29.0.2'
defaultConfig {
applicationId "..."
minSdkVersion 16
targetSdkVersion 29
versionCode 6
versionName "1.0.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
我的表格是这样的
<form id="bankPost" method="post" action="<?php echo $url; ?>" style="width: 100%;display: block;">
<input type="hidden" name="exmple" value="12">
<input type="submit" class="button-confirm" value="Accept"></form>