This simple WebView doesn't work no matter what I did. In below code I also added my if condition if it matters.
String URL = "www.google.com.tr"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if(isNetworkAvailable(this)) { Toast.makeText( MainActivity.this, "Welcome", Toast.LENGTH_LONG ).show(); mWebView = (WebView) findViewById(R.id.myWebView); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); mWebView.setVerticalScrollBarEnabled(true); mWebView.setWebViewClient(new WebViewClient()); mWebView.getSettings().setLoadWithOverviewMode(true); mWebView.getSettings().setUseWideViewPort(true); mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); mWebView.setWebChromeClient(new WebChromeClient()); mWebView.loadUrl(URL); } else //Not connected { Toast.makeText( MainActivity.this, "Internet disconnected", Toast.LENGTH_LONG ).show(); } } activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:showIn="@layout/activity_main"> <WebView android:id="@+id/myWebView" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout> This WebView shows text "Welcome" so I think program should show websites without any issue. I am at my wit's end. I even tried changing Layout type, adding ChromeView instead normal web view. And tried to change content view from match_parent to wrap_content. But no luck by doing this.
I have internet permission in my Manifest