How To Convert Any Website Into an Android App Free Using ANDROID STUDIO
hello and welcome guys today in this post I going to show you how to convert your website into an Android application using Android Studio.
friends first open Android Studio so click on Start and open.
- now click on a file then new and click on a new project.
- here select an empty activity then click on the next.
- now type your application name
- select language as Java then click on finish.
now wait for a while till the processor tobe completed. friends you need to copy and paste the code in which I will provide.
all the code that you need to use in your Android application so visit this page techproadvice.blogspot.com
now you will see this interface maximize first thing you have to do here is the same file and folders so click on app then manifests and click on android manifest.xml double click on it and here you will find this option package so actually this third line press enter.
and copy this first code
it’s a user permission code to copy
and paste here
now click on activitymain.xml if you see this interface click on code you will find this option here and in some Android versions you will find this option on this side so click on code we are now activitymain.xml remove this code from the text view till here
now friends you need to remove this text from the Android TV layout so remove this code
and type relative
so as we can see now on both sides we have the relative layout and after that click on a design
so you will see this interface now click on this search icon and type web
so you will find this webview drag and drop here
now again visit my site and copy this second code
now again click on the code so you will see the web view press enter and paste that code
now click on this res folder to expand now expand values
and double-click on styles
here you need to change dark into no so select dark test
remove it and type no and capital
now click on main activity Java click on these three dots
now enter underneath bundle visit my site and copy these three code
and passed underneath the bundle so as you can see this is the third line
now again visit my site and copy this third code
and paste underneath public class so it’s line number 10 app compact activity so enter here and paste this one
now again visit and copy this phi code line
and paste the activity menu click here
again visit the site now and copy this code
now enter after this symbol
so as we can see our cursor is between symbol and paste here
now we will find some error so you need to press the alter key plus enter
so that error will be gone friends you need to import class so sometimes this error will be gone by pressing the alt key plus enter and sometimes you will over your cursor here so underneath you will find the option import class so just need to click on that import class okay now last thing you have to do you load your website URL in here so remove from here this double quote till this double quote remove that one and paste your website URL and after that click on build then click on generate signed bundle
now select apk click on the next
now click on Create New key store path so now save in your pc path of this apk If you click on this folder icon it will show all directories so select where you want to save in my case I want to save in D Drive so give the name for that application
then click on ok now enter the password
again enter the password you can enter the same
password now validity there is a 25 you can increase if you like
now enter your first name and last name for a certificate for this application
now enter the organization city-state and country code
then click on ok
now check this box remember the password if you like and after that click on the next
now select release check both boxes and click on finish
now as we can see generated the signed APK successfully now click here and click on locate
now your application APK is ready click on it click on rename type apk name
now friends you need to add an icon for an application so click on rest right click on drawable move your cursor to new then click on image assist
now select an image as the type of icon now add the icon from your pc so you need to make ready an icon 500 by 500
I have the icon in my D Drive this one so select it and click on ok
now
you can adjust your icon like by resizing if it will be okay here in Google Play Store so it will be okay for every platform
after that click on next
then click on finish
now again click on build generate signed bundle APK select APK next next release check box box and click on finish as we can see now our application is ready click on locate
this first one so again change the name if you want to test this application click on this run icon
so as we can see now our application is ready
if you want to install it on your mobile there is a very simple and easy method firstly look out for that apk
like in my case I have my APK in here so copy it and paste on your desktop
now download it on the drive
now open that apk on your mobile device so I can open my drive
this one and we have this tech advice apk just now we created
click on install click on install anyway click on open
that’s it friends I hope you like this post, with this easy and very simple method you can convert your website into an application using android studio hopefully like this video thanks for watching this video please subscribe to this channel for the latest update.
in this post, I will show you how you can create a fully working Android app using just your website in just a few minutes. there are some easy steps.
1. WebView Android App Code:
Activity_Main.xml
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://naatly.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://naatly.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://naatly.com/"; // 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">
How to Create a book app Using Android Studio
Fix: System32 Folder Keeps Popping up at Startup
How to fix System32 folder takes too much space in Windows
HTTrack Website Copier Mirror Error Problem Solve
Optimizing RAM Usage: How to Stop Virtual Machines and vmmem Simultaneously
<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" />