Android SDK

From ETC Public Wiki
Jump to: navigation, search

How to deploy web application to the Android:

In order to publish our application in the app store, we need to create Android project.

Using WebView in Android SDK we can make our web application looks like native android application.


To develop web application with android we need to import follow settings (Java file)

import android.webkit.WebView;
import android.webkit.WebSettings;
import android.webkit.WebChromeClient;


To get setting to control WebView instance (Java file)

WebSettings settings = browser.getSettings();


To enable Javascript add below code in your java code. (Java file)

settings.setJavaScriptEnabled(true);


To use chrome browser

browser.setWebChromeClient(new WebChromeClient());


To use localstorage in HTML5 (Java file)

settings.setDomStorageEnabled(true);


To load HTML page in your webview (Java file)

browser.loadUrl("file:///android_asset/YOURWEBPAGE.html");
  • Note: In case of you put your HTML, CSS, Javascript and all other asset files under assets in Android project path will be "file:///android_asset/"


To create webView in Android declare webVie in your layout xml file ( XML file)

<WebView android:id="@+id/NAME"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>


To remove status and title bar add below code in AndroidMenifest.xml (XML file)

<activity android:name="Your App Name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">


Same parts with iPad deployment

- To handle touch events you can use same code


Differences from iPad deployment (we will keep update this part)

  • Empty space is not allowed in folder name (ex: file:/Background Image -> file:/BackgroundImage)
  • Android devices have different resolution
  • Web application based on Chrome browser.