Creating an Android app quickly and getting it published need not be as difficult as you might think. By making use of a WebView it can take just minutes to create an Android App; even if you have little android development experience.
A WebView is an android view that basically displays a webpage; if you have an existing web site or application you can turn it into an android app using a WebView and it is very easy.
Once you have created a new android project paste the following code into your main.xml in the layout folder:
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
Here we are telling the app to display a WebView that fills the full space of the device screen.
From here all we need to do is point the WebView to the correct URL for your site/app. In the code for the main activity add the following private class:
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
This piece of code tells the app that we want all further URLs and links accessed in the WebView to open in the WebView. If we did not override URL loading, any further links would be opened in the devices main web browser.
The final piece of code required is for the onCreate() event of your main activity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView webview = (WebView)findViewById(R.id.webview);
webview.setWebViewClient(new MyWebViewClient());
webview.getSettings().setJavaScriptEnabled(true);;
webview.loadUrl("http://www.bubblepixel.co.uk");
}
The onCreate code sets the layout we want to use, gets a reference to the WebView and loads the initial URL of the WebView.
You have now successfully created an Android App which can be published to the Android Marketplace. The WebView is very useful if you want to convert existing web applications quickly into an Android App.


