How to create a webview app using android studio

Thanks for visiting my website, and we are here to teach you one new lecture that is the name of how to create a web view app using android studio.

We can also use for earning app because this app is help us to make a web page and you can add some ads such as google admob ads it helps you to make for money.

So lets start 
and please follow my steps :

Step 1 :

go to activity_main.xml

<?xml version=”1.0″ encoding=”utf-8″?>
<RelativeLayout 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”
tools:context=”.MainActivity”>

<WebView
android:id=”@+id/webview”
android:layout_width=”match_parent”
android:layout_height=”match_parent” />

</RelativeLayout>

Step 2 :

go to MainActivity.java

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends AppCompatActivity {
private WebView webView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

webView = (WebView) findViewById(R.id.webview);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl(“http://www.google.com”);

WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
}

@Override
public void onBackPressed() {
if (webView.canGoBack()) {
webView.goBack();
} else {
super.onBackPressed();
}
}
}

Step 3 :

go to AndroidManifiest.java

  <uses-permission android:name=“android.permission.INTERNET” />
 

That’s it, friends, this is the correct and simple way to create webview android app using android studio. Just follow the above steps and copy paste code carefully at the correct location mentioned above.

if you found this article helpful please do comment below and share the article to support me. if you have any suggestion please feel free to comment below.

Leave a Comment

Your email address will not be published. Required fields are marked *