6

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

Tughi
  • 1,093
  • 1
  • 11
  • 20

1 Answers1

9

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()) {
        // ...
      }
    }
Tughi
  • 1,093
  • 1
  • 11
  • 20
  • 3
    Same as the answer for this question, just to relate them for reference: http://stackoverflow.com/questions/3449098/enable-longclick-in-webview (and that's a bit different for the record, that's not just long click, thats context menu) – Charlie Collins Feb 07 '11 at 20:55