Andriod


1. WebView Android App Code:

Activity_Main.xml

<WebView

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:id="@+id/webView"

android:layout_alignParentTop="true"

android:layout_alignParentLeft="true"

android:layout_alignParentStart="true"

android:layout_alignParentBottom="true"

android:layout_alignParentRight="true"

android:layout_alignParentEnd="true"

tools:ignore="MissingConstraints" />

MainActivity.java

import android.os.Bundle;

import android.webkit.WebView;

import android.webkit.WebViewClient;


import androidx.appcompat.app.AppCompatActivity;


public class MainActivity extends AppCompatActivity {


String websiteURL = "https://coupon.technovedant.com/"; // sets web url

private WebView webview;


@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);


//Webview stuff

webview = findViewById(R.id.webView);

webview.getSettings().setJavaScriptEnabled(true);

webview.getSettings().setDomStorageEnabled(true);

webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);

webview.loadUrl(websiteURL);

webview.setWebViewClient(new WebViewClientDemo());


}


private class WebViewClientDemo extends WebViewClient {

@Override

//Keep webview in app when clicking links

public boolean shouldOverrideUrlLoading(WebView view, String url) {

view.loadUrl(url);

return true;

}

}


}

AndroidManifest.xml

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



2. Internet Connection Error:

AndroidManifest.xml

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

MainActivity.java

import android.app.AlertDialog;

import android.content.Context;

import android.content.DialogInterface;

import android.net.ConnectivityManager;

import android.net.NetworkInfo;

import android.os.Bundle;

import android.util.Log;

import android.webkit.WebView;

import android.webkit.WebViewClient;


import androidx.appcompat.app.AppCompatActivity;


public class MainActivity extends AppCompatActivity {


String websiteURL = "https://coupon.technovedant.com/"; // sets web url

private WebView webview;


@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);


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

{

//Webview stuff

webview = findViewById(R.id.webView);

webview.getSettings().setJavaScriptEnabled(true);

webview.getSettings().setDomStorageEnabled(true);

webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);

webview.loadUrl(websiteURL);

webview.setWebViewClient(new WebViewClientDemo());


}

}



private class WebViewClientDemo extends WebViewClient {

@Override

//Keep webview in app when clicking links

public boolean shouldOverrideUrlLoading(WebView view, String url) {

view.loadUrl(url);

return true;

}

}



}


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;

}


}

}

}

3. Back & Exit Feature:

MainActivity.java

//set back button functionality

@Override

public void onBackPressed() { //if user presses the back button do this

if (webview.isFocused() && webview.canGoBack()) { //check if in webview and the user can go back

webview.goBack(); //go back in webview

} else { //do this if the webview cannot go back any further


new AlertDialog.Builder(this) //alert the person knowing they are about to close

.setTitle("EXIT")

.setMessage("Are you sure. You want to close this app?")

.setPositiveButton("Yes", new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

finish();

}

})

.setNegativeButton("No", null)

.show();

}

}



4. Swipe Down to Refresh:

activity_main.xml

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout

android:id="@+id/swipeContainer"

android:layout_width="match_parent"

android:layout_height="match_parent">


<WebView

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:id="@+id/webView"

android:layout_alignParentTop="true"

android:layout_alignParentLeft="true"

android:layout_alignParentStart="true"

android:layout_alignParentBottom="true"

android:layout_alignParentRight="true"

android:layout_alignParentEnd="true"

tools:ignore="MissingConstraints" />


</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

MainActivity.java

SwipeRefreshLayout mySwipeRefreshLayout;

//Swipe to refresh functionality

mySwipeRefreshLayout = (SwipeRefreshLayout)this.findViewById(R.id.swipeContainer);


mySwipeRefreshLayout.setOnRefreshListener(

new SwipeRefreshLayout.OnRefreshListener() {

@Override

public void onRefresh() {

webview.reload();

}

}

);

private class WebViewClientDemo extends WebViewClient {

@Override

//Keep webview in app when clicking links

public boolean shouldOverrideUrlLoading(WebView view, String url) {

view.loadUrl(url);

return true;

}

@Override

public void onPageFinished(WebView view, String url) {

super.onPageFinished(view, url);

mySwipeRefreshLayout.setRefreshing(false);

}

}

import android.app.AlertDialog;

import android.content.Context;

import android.content.DialogInterface;

import android.net.ConnectivityManager;

import android.net.NetworkInfo;

import android.os.Bundle;

import android.util.Log;

import android.webkit.WebView;

import android.webkit.WebViewClient;


import androidx.appcompat.app.AppCompatActivity;

import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;


public class MainActivity extends AppCompatActivity {


String websiteURL = "https://youtube.com/technicalsangrah"; // sets web url

private WebView webview;

SwipeRefreshLayout mySwipeRefreshLayout;


@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);


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

{

//Webview stuff

webview = findViewById(R.id.webView);

webview.getSettings().setJavaScriptEnabled(true);

webview.getSettings().setDomStorageEnabled(true);

webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);

webview.loadUrl(websiteURL);

webview.setWebViewClient(new WebViewClientDemo());


}


//Swipe to refresh functionality

mySwipeRefreshLayout = (SwipeRefreshLayout)this.findViewById(R.id.swipeContainer);


mySwipeRefreshLayout.setOnRefreshListener(

new SwipeRefreshLayout.OnRefreshListener() {

@Override

public void onRefresh() {

webview.reload();

}

}

);


}



private class WebViewClientDemo extends WebViewClient {

@Override

//Keep webview in app when clicking links

public boolean shouldOverrideUrlLoading(WebView view, String url) {

view.loadUrl(url);

return true;

}

@Override

public void onPageFinished(WebView view, String url) {

super.onPageFinished(view, url);

mySwipeRefreshLayout.setRefreshing(false);

}

}


//set back button functionality

@Override

public void onBackPressed() { //if user presses the back button do this

if (webview.isFocused() && webview.canGoBack()) { //check if in webview and the user can go back

webview.goBack(); //go back in webview

} else { //do this if the webview cannot go back any further


new AlertDialog.Builder(this) //alert the person knowing they are about to close

.setTitle("EXIT")

.setMessage("Are you sure. You want to close this app?")

.setPositiveButton("Yes", new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

finish();

}

})

.setNegativeButton("No", null)

.show();

}

}


}


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;

}


}

}

}

5. Screen Rotation:

AndroidManifest.xml

android:screenOrientation="portrait">



Failed to open zip file gradle's dependency cache may be corrupt


WebView in Android with Fixed Back Button & Link | Android App from Responsive Website - 4


How To Rename The Android Studio Package


How to send push notification with android studio webview app | send notification with Android app

How to send push notification with android studio webview app | send notification with Android studio app


in this video-

1. Android studio app se notification kaise bheje

2. android studio app puss notification functionality

3. add puss notification functionality in android studio app


How To Create Splash Screen In Android Studio Java Code 2021


Push notification | Firebase push notification Android | What is push notification in Android


How to Change Android Studio Project Package Name without Errors


https://www.elsebazaar.com/blog/how-do-i-make-an-existing-android-studio-project-copy/


Android Notifications Tutorial with Example | Notification Channels - in Hindi (2019)


Android Firebase Push Notification Tutorial With Example - In Hindi (2019)


Notifications Tutorial Part 1 - NOTIFICATION CHANNELS - Android Studio Tutorial


Gradle Re download dependencies and sync project requires network


Failed to open zip file gradle's dependency cache may be corrupt


How to Convert your Website into Professional Android App Using Android Studio

https://www.technovedant.com/convert-your-website-into-professional-android-app-using-android-studio.html



How to Generate APK for Google Play Console in Android Studio (2021)


How To Publish Your First Android App On Google Play Console Step By Step In Hindi 2021




public class MainActivity extends Activity {


WebView webView;


/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

webView = (WebView) findViewById(R.id.webView1);

WebSettings settings = webView.getSettings();

settings.setJavaScriptEnabled(true);

settings.setDomStorageEnabled(true);

webView.setWebViewClient(new MyWebViewClient());

String postData = "amount=1000&firstname=mtetno&email=mttee@gmail.com&phone=2145635784&productinfo=android&surl=success.php"

+ "&furl=failure.php&lastname=qwerty&curl=dsdsd.com&address1=dsdsds&address2=dfdfd&city=dsdsds&state=dfdfdfd&"

+ "country=fdfdf&zipcode=123456&udf1=dsdsds&udf2=fsdfdsf&udf3=jhghjg&udf4=fdfd&udf5=fdfdf&pg=dfdf";

webView.postUrl(

"http://host/payment.php",

EncodingUtils.getBytes(postData, "BASE64"));


}


private class MyWebViewClient extends WebViewClient {

@Override

public boolean shouldOverrideUrlLoading(WebView view, String url) {

webView.loadUrl(url);

return true;

}


@Override

public void onReceivedSslError(WebView view, SslErrorHandler handler,

SslError error) {

handler.proceed();

}

}

}


<?xml version="1.0" encoding="utf-8"?>

<manifest ...>

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

<application

...

android:usesCleartextTraffic="true"

...>

...

</application>

</manifest>


https://www.codegrepper.com/code-examples/java/cleartext+not+permitted+android+webview

You need to use a different version code for your APK or Android App Bundle in Google Play

Version code 1 has already been used. Try another version code.