Reputation: 1163
In my webview I am going to http://www.nsopw.gov/Core/OffenderSearchCriteria.aspx when this is done via the android browser it is seen as a mobile site.
But in my app in a webview it is seen as not a mobile browser therefore not being redirected to the mobile version.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.buttons);
wb = new WebView(this);
wb.getSettings().setJavaScriptEnabled(true);
wb.setWebViewClient(new HelloWebViewClient());
wb.getSettings().setSupportZoom(true);
wb.getSettings().setBuiltInZoomControls(true);
wb.getSettings().setDomStorageEnabled(true);
String[] loading = getResources().getStringArray(R.array.array_loading);
Random r = new Random();
int rN = r.nextInt(12 - 1) + 1;
progressBar = ProgressDialog.show(Sex_Offenders.this, loading[rN],
"Loading...");
final String urlToLoad ="http://www.nsopw.gov/Core/OffenderSearchCriteria.aspx";
//final String urlToLoad = "http://m.familywatchdog.us/m_v2/msa.asp?es=&l=0&w=0&brtp=html&rstp=xlarge&imgtp=jpg&imgw=310&imgh=320";
wb.setWebViewClient(new HelloWebViewClient() {
public void onPageFinished(WebView view, String url) {
if (progressBar.isShowing()) {
progressBar.dismiss();
}
}
});
Context context = getApplicationContext();
if (Repeatables.isNetworkAvailable(context) == true) {
wb.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
wb.loadUrl(urlToLoad);
} else {
wb.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
wb.loadUrl(urlToLoad);
Repeatables.NoConnectionAlert(this);
}
setContentView(wb);
Upvotes: 1
Views: 3550
Reputation: 2357
try forcing the user agent string yourself, as it appears that the webview user agent string is not identifying itself as a mobile browser. use
webview.getSettings.setUserAgentString(...)
You can google for the useragent string, I used
Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
and it worked with the link you provided in your site and loaded the mobile version.
Upvotes: 6