How to Make Multi WebView Android Application | Multi WebView Free Source Code

Now WebView Application making is very Easy with Our Source Code

We Will Provide you a Free Source Code Of Multi WebView Android Application, Follow To Our Instructions.

  1. Open Your Build.gradle ( Module ) In Android Studio And Change it with the our Dependencies given Below
dependencies {

implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

}

2. open your activity_main.xml In Android Studio And Change it with the our Code given Below

<?xml version="1.0" encoding="utf-8"?>
<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"
android:background="#EDEDED"
tools:context=".MainActivity"
>




<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="05dp"
android:layout_marginBottom="60dp"
android:orientation="vertical"
>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
>

<TextView
android:id="@+id/demoName"
android:layout_width="0dp"
android:layout_height="42dp"
android:layout_marginStart="60dp"
android:layout_marginTop="15dp"
android:fontFamily="@font/poppins_semibold"
android:text="Jyoti"
android:textColor="@color/black"
android:textSize="40sp"
app:layout_constraintEnd_toStartOf="@+id/demoImage"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

<TextView
android:id="@+id/demoDesc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="60dp"
android:layout_marginTop="10dp"
android:text="
App Developer"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintEnd_toStartOf="@+id/demoImage"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/demoName"
/>

<ImageView
android:id="@+id/demoImage"
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginEnd="25dp"
android:src="@drawable/knowledgeskey2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/demoName"
app:layout_constraintTop_toTopOf="parent"
/>

</androidx.constraintlayout.widget.ConstraintLayout>



<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_marginTop="5dp"
android:columnCount="2"
android:background="#373d3f"
android:layout_gravity="center_horizontal"
android:rowCount="4"
>

<androidx.cardview.widget.CardView
android:layout_width="170dp"
android:layout_height="150dp"
app:cardCornerRadius="12dp"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
android:layout_marginLeft="8dp"
android:layout_margin="5dp"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#EDEDED"
android:gravity="center"
>

<Button
android:id="@+id/Button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:background="@drawable/round_text_button_background"
android:textColor="@color/white"
android:text="Youtube"
android:textSize="16sp"
app:backgroundTint="#D32F2F"
/>


</LinearLayout>

</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:layout_width="170dp"
android:layout_height="150dp"
app:cardCornerRadius="12dp"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
android:layout_marginLeft="12dp"
android:layout_margin="5dp"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#EDEDED"
android:gravity="center"
>

<Button
android:id="@+id/Button2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:background="@drawable/round_text_button_background"
android:textColor="@color/white"
android:text="Facebook"
android:textSize="16sp"
app:backgroundTint="#7B1FA2"
/>


</LinearLayout>

</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:layout_width="170dp"
android:layout_height="150dp"
app:cardCornerRadius="12dp"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
android:layout_marginLeft="8dp"
android:layout_margin="5dp"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#EDEDED"
android:gravity="center"
>

<Button
android:id="@+id/Button3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:background="@drawable/round_text_button_background"
android:textColor="@color/white"
android:text="Instagram"
android:textSize="16sp"
app:backgroundTint="#303F9F"
/>


</LinearLayout>

</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:layout_width="170dp"
android:layout_height="150dp"
app:cardCornerRadius="12dp"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
android:layout_marginLeft="12dp"
android:layout_margin="5dp"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#EDEDED"
android:gravity="center"
>

<Button
android:id="@+id/Button4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:background="@drawable/round_text_button_background"
android:textColor="@color/white"
android:text="Twitter"
android:textSize="16sp"
app:backgroundTint="#0288D1"
/>


</LinearLayout>

</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:layout_width="170dp"
android:layout_height="150dp"
app:cardCornerRadius="12dp"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
android:layout_marginLeft="8dp"
android:layout_margin="5dp"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#EDEDED"
android:gravity="center"
>

<Button
android:id="@+id/Button5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:background="@drawable/round_text_button_background"
android:textColor="@color/white"
android:text="Amazon"
android:textSize="16sp"
app:backgroundTint="#00796B"
/>


</LinearLayout>

</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:layout_width="170dp"
android:layout_height="150dp"
app:cardCornerRadius="12dp"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
android:layout_marginLeft="12dp"
android:layout_margin="5dp"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#EDEDED"
android:gravity="center"
>

<Button
android:id="@+id/Button6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:background="@drawable/round_text_button_background"
android:textColor="@color/white"
android:text="Flipkart"
android:textSize="16sp"
app:backgroundTint="#689F38"
/>

</LinearLayout>

</androidx.cardview.widget.CardView>


</GridLayout>


</LinearLayout>



</RelativeLayout>

3. Now You Have to Create New Drawable Resource File ( Example – round_text_button_background )

open your New round_text_button_background File In Android Studio And Change it with the our Code given Below

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FF0000" /> <!-- Set the background color of the button -->
<corners android:radius="50dp" /> <!-- Set the radius to achieve the round shape -->
</shape>

4. Now You Have to Create New xml File ( Example – activity_main2.xml )

open your New activity_main2.xml In Android Studio And Change it with the our Code given Below

<?xml version="1.0" encoding="utf-8"?>
<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:context=".MainActivity2"
>




<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="70dp"
>

<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
tools:ignore="MissingConstraints"
/>

</LinearLayout>


</RelativeLayout>

5. open your MainActivity.java In Android Studio And Change it with the our Code given Below

import androidx.appcompat.app.AppCompatActivity;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;



public class MainActivity extends AppCompatActivity {
Button Button1, Button2, Button3, Button4, Button5, Button6;
private WebView webView;
private Intent intent;


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

if (!CheckNetwork.isInternetAvailable(this)) //returns true if internet available
{
//if there is no internet do this
setContentView(R.layout.activity_main);
//Toast.makeText(this,"No Internet Connection, Chris",Toast.LENGTH_LONG).show();


new AlertDialog.Builder(this) //alert the person knowing they are about to close
.setTitle("No internet connection available")
.setMessage("Please Check you're Mobile data or Wifi network.")
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
//.setNegativeButton("No", null)
.show();


} else {

Button1 = findViewById(R.id.Button1);
Button2 = findViewById(R.id.Button2);
Button3 = findViewById(R.id.Button3);
Button4 = findViewById(R.id.Button4);
Button5 = findViewById(R.id.Button5);
Button6 = findViewById(R.id.Button6);


Button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openWebViewActivity("https://www.youtube.com");

}
});

Button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openWebViewActivity("https://www.facebook.com");

}
});

Button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openWebViewActivity("https://www.instagram.com");


}
});

Button4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openWebViewActivity("https://www.twitter.com");

}
});

Button5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openWebViewActivity("https://www.amazon.in");

}
});

Button6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openWebViewActivity("https://www.flipkart.com");

}
});
}
}

private void openWebViewActivity(String url) {
Intent intent = new Intent(MainActivity.this, MainActivity2.class);
intent.putExtra("url", url);
startActivity(intent);


}


}
class CheckNetwork {

private static final String TAG = CheckNetwork.class.getSimpleName();

public static boolean isInternetAvailable(Context context) {
NetworkInfo info = (NetworkInfo) ((ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();

if (info == null) {
Log.d(TAG, "no internet connection");
return false;
} else {
if (info.isConnected()) {
Log.d(TAG, " internet connection available...");
return true;
} else {
Log.d(TAG, " internet connection");
return true;
}

}
}
}

6. Now You Have to Create New java File ( Example – MainActivity2.java)

open your New MainActivity2.java In Android Studio And Change it with the our Code given Below

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity2 extends AppCompatActivity {
private WebView webView;



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);


webView = findViewById(R.id.webView);
webView.setWebViewClient(new WebViewClient());


String url = getIntent().getStringExtra("url");
webView.loadUrl(url);

}

}

7. Now We Have to Add Code For Getting Internet Permission

open your Androidmanifest File In Android Studio And Add our Code given Below

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Add This Activity In Androidmanifest File

        <activity
android:name=".MainActivity2"
android:exported="false">
</activity>

Now Your Multi WebView Android Application Is Ready. Thanks

Leave a Comment