I am open my custom URL in web view in android with follow below process.
Design your webview as full screen like
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="20dp"
android:gravity="center"
android:background="#ffffff">
<WebView
android:id="@+id/WebView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"/>
</RelativeLayout>
And in you .java file add below code in onCreate method
webView = (WebView) findViewById(R.id.WebView);
windowwidth = getWindowManager().getDefaultDisplay().getWidth();
windowheight = getWindowManager().getDefaultDisplay().getHeight();
getWindow().setLayout(windowwidth, windowheight);
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setAppCacheEnabled(false);
settings.setDomStorageEnabled(true);
try {
// here i call progressdialog which is load still the page is not load //properly
Constants.ShowProgressDialog(MyActivity.this, "", "Please wait...");
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.i("", "Processing webview url click...");
view.loadUrl(url);
return true;
}
public void onPageFinished(WebView view, String url) {
Log.i("", "Finished loading URL: " + url);
// dismiss the progressbar after load the web page in webview.
Constants.disMisProgressdialog();
}
@Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
}
});
webView.loadUrl("<your url>");
} catch (Exception e) {
e.printStackTrace();
}
If still any issue please provide me your url I'll check and provide you the code.
Hope your problme resolve.
Make sure provide permission in Manifest file.
"<"uses-permission android:name="android.permission.INTERNET" />" (remove the quatation mark)