3

I have a webview that performs a search, this code works great for below android version 4.0.3, at this version and higher the highlight function fails to highlight. The search itself works and jumps the page around but nothing is shown for the result (Unless you look hard enough!).

I want to know if anyone knows of a work-around that supports higher than 4.0.3?

People in other answers have linked to these webpages as possible solutions but I am not sure how to adapt this to my webview in Android.

WebPages:

http://4umi.com/web/javascript/hilite.php#thescript
http://www.nsftools.com/misc/SearchAndHighlight.htm

Code I am using currently to search and highlight:

        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                    && ((keyCode == KeyEvent.KEYCODE_ENTER))) {
                wv.findAll(findBox.getText().toString());

                try {
                    Method m = WebView.class.getMethod("setFindIsUp",
                            Boolean.TYPE);
                    m.invoke(wv, true);
                } catch (Exception ignored) {
                }
            }
            return false;
        }
user1561757
  • 87
  • 1
  • 8

1 Answers1

3

In Android 4.1(jellybean), WebView.findAll() is deprecated, we should use WebView.findAllAsync instead.

reference

Wish this help:)

Joy Wen
  • 46
  • 4
  • 1
    Hello, I just noticed this response. I will give that a shot and fire some feedback at you or accept the answer. Thanks for stopping by with an answer! – user1561757 Aug 22 '12 at 03:46
  • That would be great but I am not ready to make the min SKD level 16. I suppose this is the correct answer but until I move the minimum SDK version up I will stay on 10. Thanks! – user1561757 Aug 22 '12 at 06:47