How to transform your website become Android app

Some of you may want to transform or convert your website become android app but do not have too much of time and skill to complete it in a given time. To convert a website to an Android application, it is just pretty easy to transform it, you just need half to 1 hour to complete it. In this tutorial, I will tell you how to transform your website to android app in Android Studio IDE.  You just need to use a WebView in Android Studio. What is Webview? Webview is a browser bundled inside of a mobile app that allow the developer to render the website in the mobile app. By using a webview, it allows mobile apps to use the web technology such as html, javacript.

Benefit

  • Save cost, you dont need to spend money to hire developer to build an android app for your website.
  • Save time, it help you to save alot of development time.
  • It will be compatible to most of the android devices.

Pre-requisites

1. Download Android Studio IDE.

2. Prepare a website that have responsive web design.

Creating a New Project

1. Open Android Studio IDE in your computer.
2. Create a new project and Edit the Application name to “WebViewExample”.
(Optional) You can edit the company domain or select the suitable location for current project tutorial. Then click next button to proceed.
3. Select Minimum SDK (API 15:Android 4.0.3 (IceCreamSandwich). I choose the API 15 because many android devices currently are support more than API 15. Click Next button.
4. Choose “Empty Project” and Click Next button
5. Lastly, press finish button.

Edit activity_main.xml Layout

Go to your activity_main.xml from layout folder, change your relative layout to webview.

Edit MainActivity.java

Go to your MainActivity.java and copy below code, your activity should be extends Activity instead of AppCompatActivity because Activity does not have toolbar.

WebSettings

– It is manage the setting of the WebView.

setJavaScriptEnabled()

– To enable or disable JavaScript ability in your WebView.

shouldOverrideUrlLoading(WebView view, String url)

– To take the control of loading the url in the WebView. It will load the url inside the WebView If the user navigate to another page.

onPageFinished(WebView view, String url)

– To notify the client for the url is finish loaded.

loadurl()

– To load your website in the WebView.

Edit AndroidManifest.xml

Last, dont forget to add INTERNET permission in your android manifest file. If you no adding the permission in manifest, the content will not able to load when you running the project.

Run your project

Now, you are able to run the application in your android device or emulator.

(How to transform your website become android app)

Source code

(Visited 278 times, 1 visits today)
Advertisements

Yong Loon Ng

Ng Yong Loon, better known as Kristofer is a software engineer and computer scientist who doubles up as an entrepreneur.

You may also like...

Leave a Reply

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