我正在我的 Webview 中加载在线 html 页面,并希望针对从 html 在线页面(而不是本地 HTML 页面)单击的特定按钮加载活动
我发现了一些东西,但这并不符合我的要求。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginsEnabled(true);
webView.setHorizontalScrollBarEnabled(false);
webView.loadUrl("https://accounts.google.com/DisplayUnlockCaptcha");
webView.setBackgroundColor(0x00000000);
webView.setOnTouchListener(new View.OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
WebView.HitTestResult hr = ((WebView)v).getHitTestResult();
Log.i("TESTING In OnTouch ", "getExtra = "+ hr.getExtra() + "\t\t Type=" + hr.getType()+
"\t\t Ancher Tag = " +HitTestResult.SRC_ANCHOR_TYPE+
"\t\t Ancher Tag = " +HitTestResult.UNKNOWN_TYPE+
"\t\t Ancher Tag = " +HitTestResult.ANCHOR_TYPE
);
return false;
}
});
}