0

I am new to webview in android. I just want to know the way how we can fetch any particular text from webview if the text is available there.

Example: I have some text on my webview like "Android works great" Here I want if the text "Android" is available on webview then do something else otherthing.

if("Android" available on webview) {
then Print("It works great")
}
else {
Print ("Useless")
}

How I can attain the same in Android. Please help me out. Thanks in Advance :)

Varun Vishnoi
  • 328
  • 6
  • 23

1 Answers1

2

It's not the best way to do it but you can get the url content and then compare it to your text

try {                   
                URL url;
                url = new URL("http://www.google.com/");

                BufferedReader in;

                in = new BufferedReader(new InputStreamReader(url.openStream()));                   

                String inputLine;
                while ((inputLine = in.readLine()) != null) {
                    if(inputLine.contains("Android")) {

                    } else {

                    }
                }
                in.close();

            } catch(Exception e) {                  
                e.printStackTrace();
            }