I'm running into an issue on kitkat (Android 4.4) devices running my app. The issue is that when I call getHitTestResult() on my webview it returns null, where as on any other version of Android it returns appropriate data. I'm not sure if this is a specific 4.4 bug or if there's a work around any one is aware of. Any help is much appreciated. Code is below:
    WebView myWebView = new WebView(getContext());
    HitTestResult hitResult = myWebView.getHitTestResult();
    if (hitResult != null && hitResult.getType() == HitTestResult.SRC_ANCHOR_TYPE) {
        CBDReaderWebClient client = new CBDReaderWebClient();
        ...
    }
But, do you have it inside a touch listener? As far as i know, that only work after something was touched (not in the precise moment, but something has to be touched)
WebView myWebView = new WebView(getContext());
HitTestResult hitResult = myWebView.getHitTestResult();
myWebView.setOnTouchListener(new View.OnTouchListener() {
  public boolean onTouch(View v, MotionEvent event) {
      WebView.HitTestResult hr = ((WebView)v).getHitTestResult();
       //...
      return false;
   }
 });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With