Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android webview: detect long press on <a> and <img>

Is there a way to detect long presses on links and images inside a WebView?

like image 288
Tughi Avatar asked Feb 07 '11 14:02

Tughi


1 Answers

I looked inside the Browser.apk source code and found what I was really looking for:

    public void onCreate(Bundle savedInstanceState) {
        // ...
        registerForContextMenu(descriptionWebView);
        // ...
    }

    public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
      WebView.HitTestResult hitTestResult = descriptionWebView.getHitTestResult();
      switch (hitTestResult.getType()) {
        // ...
      }
    }
like image 74
Tughi Avatar answered Sep 28 '22 06:09

Tughi