1

I have a simple browser app. It loads some IP and displays it using WebView. I want to access the source code of the loaded URL and store into Android string so I can use it.

For an example :

Suppose it is loaded 10.0.0.1 and the webpage shows this.

LOADED HTML FILE

So, I want to store that "HELLO THERE". And further want to process if string is equal to "HELLO THERE", a toast will be shown.

I managed to load the URL, and I know how to make Toast. The problem is, I am not able to store that "HELLO THERE" in string.

Solution Tried :

  1. http://blog.weinigel.se/2014/03/05/getting-html-source-from-android-webview.html
  2. Is there a way to get the HTML in a webview in an Android app?
  3. How I get page source from WebView?

I have tried all of above solutions. But, none worked. It would be great if I get the answer using specific scenario of mine.

3
  • Can you tell if there was some exception thrown or error using those solutions or it just didn't do anything? Also your implementation could have been wrong Commented Apr 12, 2021 at 13:58
  • Try this: stackoverflow.com/a/10268764/9796205 Commented Apr 12, 2021 at 15:47
  • @javdromero there's no exception or error. Atleast not that catch (Exception e) block printed. Commented Apr 14, 2021 at 10:51

1 Answer 1

0

I found my quesntion's solution in this post.

https://stackoverflow.com/questions/6503574/how-to-get-html-source-code-from-url-in-android[][1]

I don't know much about Ion dependency but it did my work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.