Android application development (WebView application)

October 2, 2014   Ohsik Park

Android Developer Tools v22.6.2. Creating an android web application with splash screen and history back button with JavaScript enabled.

File > New > New Android Application

create-new-andorid-application

Enter your project name and click next. Click next again on next screen

set-up-your-home-icon

Select your application’s home icon then hit next. On next screen, just hit next. Hit finish on the following screen.

Locate WebView on phone screen (activity_main.xml)

add-WebView-on-the-screen

Drag and drop WebView(Under Composite) on screen in activiy_main.xml which you can find under res > layout > activity_main.xml. You can remove fragment_main.xml file in the folder. Select Theme to Theme.Black.NoTitleBar to remove top bar in order to make WebView takes entire screen.

Adding WebView should create code above on your activity_main.xml file.

Load website on WebView (MainActivity.java), enable Javascript and Back button

MainActivity-java

MainActivity.java file located under src > com.rubstr.rubstr > MainActivity.java.

Adding splash screen or loading screen

add-splash-screen-image-in-the-project

Create a folder called drawable under res folder and add your splash screen image. I created splash screen as 480X800 and named it as splash.png (some reason it does not work with other names).

Next, create a new file called SplashActivity.java under src > com.rubstr.rubstrnews. Right click on the folder > New > Other > General > File click next and name it SplashActivity.java. Add below code in there.

Note that, if activity_splash text gets red underline, mouse over the cursor for couple seconds to see help text. Select create activity_splash in layout which will add activity into R.java file under gen > com.rubstr.rubstr > R.java. Do the same for splash on the bottom of the code.

Next, create new file called activity_splash.xml under res > layout folder. Add below code.

This will add splash image as background on the screen. Make sure you named the image as splash.png in res > drawable folder.

Add internet permission & splash screen (AndroidManifest.xml)

AndroidManifest-xml

AndroidManifest.xml under top root of your Android project. At this point, you can do a test run by clicking green play button on the top or Run > Run(Run as Android application) on main menu

Run a test

Run your app by clicking green play button on the top or Run > Run. Select run as Android application. Check everything works ok.

Export out as APK for Google Play Store

Right click on the project folder in Package Explorer. Select Android Tools > Export Signed Android Package… Then follow the instruction to get APK file. After exporting APK file for your application, test it on your Android Phone. Everything works Okay? then you can upload it to Google Play Store.

Publish your android application on Play Store

You have to pay $25 to get the developer account which will allow you to publish your app on Google Play Store. Visit https://play.google.com/apps/publish/ to sign up

Leave a Reply

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