我的应用程序遇到了诸如修复跨应用程序脚本漏洞的错误。 我尝试了几种方法来查看相关文档,但无法解决。
https://support.google.com/faqs/answer/9084685
我还参考了以下链接的文档
我们如何解决问题?
附上有问题的部分的来源
@Override
@SuppressLint("SetJavaScriptEnabled")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.searchimage);
Intent intent = getIntent();
url = intent.getStringExtra("URL");
vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
webview = (WebView) findViewById(R.id.wbsearch);
webview.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (v == webview) {
vib.vibrate(300);
WebView.HitTestResult hitTestResult = webview.getHitTestResult();
switch (hitTestResult.getType()) {
case WebView.HitTestResult.UNKNOWN_TYPE:
downImageUrl = hitTestResult.getExtra();
Toast.makeText(getApplicationContext(), "Image save failed", Toast.LENGTH_SHORT).show();
break;
case WebView.HitTestResult.SRC_ANCHOR_TYPE:
downImageUrl = hitTestResult.getExtra();
Toast.makeText(getApplicationContext(), "Image save failed", Toast.LENGTH_SHORT).show();
break;
case WebView.HitTestResult.IMAGE_TYPE:
downImageUrl = hitTestResult.getExtra();
http = downImageUrl.substring(0,4);
if(http.equals("http"))
{
new ImageDownAsyncTask().execute(downImageUrl);
}
else
{
Toast.makeText(getApplicationContext(), "Image save failed", Toast.LENGTH_SHORT).show();
}
break;
case WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE:
downImageUrl = hitTestResult.getExtra();
http = downImageUrl.substring(0,4);
if(http.equals("http"))
{
new ImageDownAsyncTask().execute(downImageUrl);
}
else
{
Toast.makeText(getApplicationContext(), "Image save failed", Toast.LENGTH_SHORT).show();
}
break;
case WebView.HitTestResult.IMAGE_ANCHOR_TYPE:
downImageUrl = hitTestResult.getExtra();
http = downImageUrl.substring(0,4);
if(http.equals("http"))
{
new ImageDownAsyncTask().execute(downImageUrl);
}
else
{
Toast.makeText(getApplicationContext(), "Image save failed", Toast.LENGTH_SHORT).show();
}
break;
default:
Log.i("sinwhodebug", "in switch = " + hitTestResult.getType());
break;
}
}
return true;
}
});
if (19 <= Build.VERSION.SDK_INT) {
webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
}
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setSupportZoom(true);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setDisplayZoomControls(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
webview.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
webview.getSettings().setUseWideViewPort(true);
webview.setLongClickable(true);
webview.loadUrl(url);
webview.setWebViewClient(new SearchWebViewClient());
}