It's very simple try integrate these lines of code first take permission in the Android Manifest file
<uses-permission android:name="android.permission.INTERNET" />
then write some code in you Activity.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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:context="com.example.MainActivity"> <WebView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/help_webview" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>
Then write these code in your MainActivity.java
import android.app.Activity; import android.content.Intent; import android.content.res.Resources; import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.KeyEvent; import android.view.Window; import android.webkit.WebResourceRequest; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Toast; public class MainActivity extends Activity{ private WebView mWebview ; String link = "";// global variable Resources res;// global variable @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_modernherbal_main); mWebview = (WebView) findViewById(R.id.help_webview); WebSettings webSettings = mWebview.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setUseWideViewPort(true); webSettings.setLoadWithOverviewMode(true); final Activity activity = this; mWebview.setWebViewClient(new WebViewClient() { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Toast.makeText(activity, description, Toast.LENGTH_SHORT).show(); } }); mWebview .loadUrl("http://www.example.com"); }
}
Try this it'll help you to solve your problem