Here, You can find Solution of How to true a website into an app.
Below listed step by step process to convert Website to Web view mobile app.
Step 1: Install Android Studio. you can download Android Studio from here from the Android Studio Offical Website.
Step 2: Create a New Blank Project
New => Create New Project Select Blank Activity Change Your Project Name, Directory Path, and Select Language as JAVA.
Step 3: Go To Left Side Menu Select app => manifests
Select AndroidManifest.xml
Add Below Code into it and Save it.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.sridix"> <uses-permission android:name="android.permission.INTERNET"></uses-permission> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
Step 4: Add Code to activity_main.xml
<?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=".MainActivity"> <WebView android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout>
Step 5: Add Below Code to res => values => styles.xml
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> </resources>
Step 6: Add below code to MainActivity.java
package com.sridix; import androidx.appcompat.app.AppCompatActivity; import android.graphics.Bitmap; import android.os.Bundle; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends AppCompatActivity { private WebView mywebView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mywebView=(WebView) findViewById(R.id.webview); mywebView.setWebViewClient(new WebViewClient()); mywebView.loadUrl("https://www.learningcontainer.com/"); WebSettings webSettings=mywebView.getSettings(); webSettings.setJavaScriptEnabled(true); } public class mywebClient extends WebViewClient{ @Override public void onPageStarted(WebView view, String url, Bitmap favicon){ super.onPageStarted(view,url,favicon); } @Override public boolean shouldOverrideUrlLoading(WebView view,String url){ view.loadUrl(url); return true; } } @Override public void onBackPressed(){ if(mywebView.canGoBack()) { mywebView.goBack(); } else{ super.onBackPressed(); } } }
Step 7: Application ICON
Drawable => Add New => Image Asset Select Image and Finish it.
Step 8: Create APK
Go To Build => Generate Signed Bundle/APk Select APK Next Select Create New... Add Specific Details like Password, Name, Organizations, City, State, Country Code. Then Next Last Window select release and bottom select both Signature Versions: V1( Jar Signature) V2 and then Finish.
You are Done. APK is Ready.