WebView not Working Properly
Probably you forgot to activate Javascript in the WebView.
Please try this:
webSettings.setJavaScriptEnabled(true);
instead of:
webSettings.getJavaScriptEnabled();
A couple of other settings could help:
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setAllowFileAccess(true);
settings.setAllowContentAccess(true);
settings.setAllowFileAccessFromFileURLs(true);
settings.setAllowUniversalAccessFromFileURLs(true);
settings.setDomStorageEnabled(true);
Android WebView Not Loading Correctly
I got it working by setDomStorageEnabled(true);
You need to set this when using local storage.
WebView not loading certain pages
Use below code and it should work, I tested and it worked.
public class WebViewEx extends AppCompatActivity {
private WebView webView;
private ProgressDialog progDailog;
Activity activity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view_ex);
webView = findViewById(R.id.webView);
activity = this;
progDailog = ProgressDialog.show(activity, "Loading", "Please wait...", true);
progDailog.setCancelable(false);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setDomStorageEnabled(true);
webView.setWebChromeClient(new WebChromeClient());
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
progDailog.show();
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, final String url) {
progDailog.dismiss();
}
});
webView.loadUrl("https://6awlanow.com/about/faqs");
}
}
Your XML will be like below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Below is the result I got in WebView:
I hope this will resolve your issue and let me know if you have any query.
Webview does not load a particular website
I had the similar issue. after a long research, i added so many codes its start working. this is not the right answer, but my Angular website starts working on adding this code. check and please let me know if it's helpful.
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAllowContentAccess(true);
webView.loadUrl(url);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setDomStorageEnabled(true);
webView.clearView();
webView.setHorizontalScrollBarEnabled(false);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setDatabaseEnabled(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
webView.getSettings().setDatabasePath("/data/data/" + this.getPackageName() + "/databases/");
}
webView.setVerticalScrollBarEnabled(false);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setPluginState(WebSettings.PluginState.OFF);
webView.setScrollbarFadingEnabled(false);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webView.setInitialScale(1);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.loadUrl(request.getUrl().toString());
}
return false;
}
});
webview not loading correctly in application
First, you need android.permission.INTERNET permission.
Second, you may need setJavaScriptEnabled(true) to settings, and do loadUrl at the very last.
webview.getSettings().setBuiltInZoomControls(true);
webview.setInitialScale(1);
webview.getSettings().setAppCacheEnabled(false);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://canyonculberts.com/ucc/?page_id=93");
Website doesn't load properly on webview
What you are missing is more configuration of your WebViews settings.
My guess is that you need to allow Dom, local data storage and more.
Add these permissions and if they solve it try finding the unnecessary ones.
wv.getSettings().setAllowContentAccess();
wv.getSettings().setAllowFileAccess();
wv.getSettings().setDatabaseEnabled();
wv.getSettings().setDomStorageEnabled();
I also suggest you try out the new API created for Chrome Custom Tabs - creating your own Chrome-tab in your app.
https://developer.chrome.com/multidevice/android/customtabs
webview not loading particular url
Try this
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView = findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setDomStorageEnabled(true);
webView.setWebViewClient(new WebViewController());
webView.loadUrl("http://api.tixbag.com/test.php");
}
public class WebViewController extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
OUTPUT
Related Topics
Size of Json Object (In Kbs/Mbs)
Swiper Slider - Thumbs Gallery With Slidetoclickedslide Do Not Work Properly
Mongodb Get Data to Display in HTML
Remove Double Quotes from Array in Angularjs
Formdata Created from an Existing Form Seems Empty When I Log It
Javascript Restrict Text Field to Numbers and Decimals
Best Way to Show a Loading Spinner/Gif While My React Component Is Fetching Via Ajax
How to Show a Confirmation Dialog Box in Toastr
Converting Text to Unicode in JavaScript
How to Change Image and Text Color When Clicking Using React-Native
Property Does Not Exist on Type 'Never' Typescript/React
Prevent Any Form of Page Refresh Using Jquery/Javascript
Avoid a Link to Reload the Page in JavaScript
React: How to Inject React Component into Body
Retrieving Json Response Data With Dynamic Key