Url Not Loading In Webview But Loaded In Browser In Android?
Some type of Urls are not loading in my app in Webview but it can be loaded in device browser. Following is the example Url which is not working in my code- 'http://apps.takeyourap
Solution 1:
Create WebViewClient
and load url
like
publicclassmyWebClientextendsWebViewClient {
@OverridepublicbooleanshouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
view.loadUrl(url);
returntrue;
}
}
And setWebViewClient
like:
webView.setWebViewClient(new myWebClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://apps.takeyourapp.com/testApp/staging/index.html");
And also add INTERNET
permission into manifest.xml
<uses-permissionandroid:name="android.permission.INTERNET" />
Solution 2:
Try this solution.
publicclassMainextendsActivity {
private WebView mWebview ;
@OverridepublicvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mWebview = newWebView(this);
mWebview.getSettings().setJavaScriptEnabled(true); // enable javascriptfinalActivityactivity=this;
mWebview.setWebViewClient(newWebViewClient() {
publicvoidonReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
}
});
mWebview .loadUrl("http://apps.takeyourapp.com/testApp/staging/index.html");
setContentView(mWebview );
}
}
Post a Comment for "Url Not Loading In Webview But Loaded In Browser In Android?"