I'm about to give up, because I've spent hours and hours on this issue, I even found people with the exact same problem, running almost the exact same code, and no answers for them.
I have a webpage that I do not own, but I copy it's page source into my HTML file in the assets folder.
The webview loads the page and whatever data is displayed at the time. Problem #1: the page is dynamic, it changes every few seconds.
Problem#2: The page is displayed just like in the 2 links below. Images are missing, the page looks really barebones.. I don't know why.
WebView not showing website correctly and WebView not showing correctly
Problem#3: SOME pages that load, look fine and I can visit their links, BUT they stay static, and the page is very dynamic (think reddit).
my code is
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//get reference to webview
WebView webView = (WebView)findViewById(R.id.myWebview);
//enable javascript on browser
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url){
view.loadUrl(url);
return false;
}
});
String myUrl = "file:///android_asset/newfile.html";
webView.loadUrl(myUrl);
}
When I try using webView.loadDataWithBaseUrl();
the webview only displays a white page with just the path to my html file
for example
file:///android_asset/newfile.html
and thats it.
I am out of ideas, I hope someone can help.
EDIT: Grammar and syntax.