I have a very similar webview code on my project, I just replaced the urls you have provided.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_agreement);
WebView webView = (WebView) findViewById(R.id.userAgreementView);
final ProgressWheel progressWheel = (ProgressWheel) findViewById(R.id.progress_bar);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setDomStorageEnabled(true);
//webView.getSettings().setUserAgentString("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
Log.v("UA", webView.getSettings().getUserAgentString());
String url = getIntent().getStringExtra("data"); //Urls provided by other activity
if (url != null && !url.equals("")) {
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
//progress wheel fills here etc.
// ...
// ...
}
}
});
webView.loadUrl(url);
}
}
http://onlinelibrary.wiley.com/doi/10.1002/art.39115/pdf this one loaded like a charm in the webview with no glitches and no wrong behavior.
Then I tried this one http://www.ajpmonline.org/article/S0749-3797(14)00628-X/fulltext, when the webview completes loading a new native Chrome activity starts immediately and loads the mobile version of the page in a separate activity.
I checked the behavior of the website with my desktop Chrome, when I make an http request with a Android user agent string it turns out to do the following things.
- Return 302 status code and redirect to http://www.ajpmonline.org/action/mobileChoice?originalRequestUri=%2Farticle%2FS0749-3797%2814%2900628-X%2Ffulltext&userInterface=mobile
- Set a cookie called MobileUI and redirect to original page with an 302 status code.
- Load the mobile version of the page depending on the MobileUI cookie. At that point website may be running a javascript code to popup a new window, which explains the behavior on my Galaxy S4 mini.
Then I decided mimic the user agent string as a desktop browser. I picked a UA string from http://www.useragentstring.com/pages/Chrome/ and set it like this before the loadUrl method and voilà!
webView.getSettings().setUserAgentString("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
Log.v("UA", webView.getSettings().getUserAgentString());
This may be an edge case scenario and depending on the URL you are loading behavior may change but you can force to load desktop version of the websites with a proper user agent string.