I have a Website that has some double click functionality and so with android when you double click in the browser it will just zoom. So I am building a WebView so I can over ride the double click and make it react like it should.
public class myWebView extends Activity{
GestureDetector gs = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView engine = (WebView) findViewById(R.id.web_engine);
engine.getSettings().setJavaScriptEnabled(true);
engine.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
engine.getSettings().setSupportMultipleWindows(true);
engine.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
return super.onJsAlert(view, url, message, result);
}
});
engine.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
engine.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (gs == null) {
gs = new GestureDetector(
new GestureDetector.SimpleOnGestureListener() {
//overrides the double click
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
// SOME CODE THAT SIMULATES A DOUBLE CLICK
return true;
}
});
}
gs.onTouchEvent(event);
return false;
}
});
engine.loadUrl("http://www.google.com");
}
}
So the function onDoubleTapEvent(MotionEvent e) will do whatever is in between in the event of a double click. The above code is mostly thanks too Cehm.
So at this point I need to trick it to executing a a double click. Can I just simulate a Couple of click in there?