I have a web page stored in my res/raw folder in android app. I want to access it and load it in the webview in my activity. Can anyone please tell me how am I supposed to do that. I have tried
webView.loadUrl(getResources().openRawResource(R.raw.myHtmlPage).toString());
but it dint work rather it gives a broken page.
kindly help me out.
regards FAS
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken web view to show html content.
Yes you can, you can use javascript to get webpage content. Then use the webview jsInterface to return the content to you java code.
The loadUrl() and loadData() methods of Android WebView class are used to load and display web page.
Do you mean you have the raw html as a string such as "<html>...</html>"
?
If so then Webview.loadData()
or Webview.loadDataWithBaseUrl()
should work.
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