Android Container

Table of Contents

Overview

The Android device container is a standard Android native Application. It's implementation includes the following Activities:

  • ICEmobileContainer implements the web container view using a WebView.
  • ContainerPreferences implements a preference view using standard PreferenceActivity and XML PreferenceScreeen definition.
  • HistoryList implements a chronologically ordered history of URLs that have been viewed in the container, and is based on a standard ListActivity.

Device capability integrations are implemented as separate libraries that can be included in the device container as desired. Each device capability integration library contains a JavaScript to Java interface and an implementation of the specific device capability. JavaScript to Java interfaces are exposed to web pages using standard WebView addJavascriptInterface() calls.

Activities

The Activities available in the container are defined in the AndroidManifest.xml file.

    <activity android:name="ICEmobileContainer"
              android:label="@string/app_name"
	      android:launchMode="singleTop"
	      android:configChanges="keyboardHidden|orientation">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <activity android:name=".ContainerPreferences"/>
    <activity android:name=".HistoryList" android:label="@string/history_name"/>
    <activity android:name="org.icemobile.client.android.qrcode.CaptureActivity"
              android:label="@string/app_name">
    </activity>

ContainerPrefrences and HistoryList Activities can be included/excluded from the container application by including/excluding them from AndroidManifest.xml. If excluded, the Options Menu should be modified accordingly.

ICEmobileContainer

The ICEmobileContainer Activity is the main Activity for the device container and presents the web application interfaces in a WebView. There are a number of different aspects of the container that can be customized to meet application-specific requirements, including:

  • Home URL is the initial URL that the application loads when first started, and is controlled by a constant.
    protected static final String HOME_URL = "http://your_url";
  • Device Capabilities can be included/excluded with a set of constants
    protected static final boolean INCLUDE_CAMERA = true;
    protected static final boolean INCLUDE_AUDIO = true;
    protected static final boolean INCLUDE_VIDEO = true;
    

    Integration library inclusion in the build process is controlled from the project.properties file, as follows

android.library.reference.1=../integration/util/
android.library.reference.2=../integration/camera/
android.library.reference.3=../integration/audio/
android.library.reference.4=../integration/video/
android.library.reference.4=../integration/qrcode/
  • Options Menu is defined in the XML file dev_menu.xml. Options menu processing is implemented in ICEmobileContainer.onOptionsItemSelected(). Standard container options include:
    • Reload reload the current current page.
    • Preferences starts the ContainerPreferences Activity.
    • History starts the UrlHistory Activity.
    • Stop stops the ICEmobileContainer Activity.
  • Preference Handling is implemented in ICEmobileContainer.onSharedPreferenceChanged() as per the SharedPreferences.OnSharedPreferenceChangeListener interface.
  • URL History Size is controlled by a constant.
    protected static final int HISTORY_SIZE = 20;

ContainerPreferences

The ContainerPreferences Activity extends the standard PreferenceActivity. The set of preferences is defined in the XML file preferences.xml. The ICEmobileContainer implements the onSharedPreferenceChanged() listener. The following stock preferences are supported:

  • New URL allows you to specify a new URL to navigate to.
  • Use Photo Gallery allows you to specify that photos should be selected from the device's media gallery vs. using the camera to capture a new photo.
  • Use Video Gallery allows you to specify that videos should be selected from the devices media gallery vs. using the video camera to capture a new video.
  • Email Notification allows you to specify an email address to send cloud notification messages to.
  • Progress Dialog enables/disables a progress dialog during page loading
  • Hardware Acceleration enables/disables hardware acceleration on Android 3.x tablets.

HistoryList

The HistoryList Activity implements a list of recently visited URLs and is based on a standard ListActivity. The size of the history list is set in the constructor, and is controlled by a constant in the ICEmobileContainer Activity.

Application Branding

The ICEmobileContainer performs no specific branding of the container view itself, so all branding of the UI is achieved in the web application. The following elements of the container can be modified to brand the native container application.

  • Application Name is specified in the strings.xml file.
    <string name="app_name">ICEmobileContainer</string>
  • Application Icon is specified in the AndroidManifest.xml file.
    <application android:label="@string/app_name" android:icon="@drawable/icon">

    The icon itself exists in the res/drawable directories for the container. The application icon should be provided in hdpi, mdpi, and ldpi variants.

Build Environment

The ICEmobileContainer build environment is based on standard Android command line project management support, and utilizes the ant build tool. The source code is split into separate container and integration directories, with the device integration capabilities implemented as separate library projects under the integration directory.

Device Container

The device container lives in the directory mobi/client/android/container. The debug version of the container can be installed on a device or emulator with the commands

ant -Dsdk.dir=/path/to/your/android-sdk-mac_x86/ debug
ant installd

Integration libraries to be included in the build are defined in the project.properities file.

Integration Libraries

Each of the device integration capabilities is included as a separate library project in the directory mobi/client/android/integration. An individual library can be built with the command

ant debug

Application Deployment

To deploy your customized Device Container in a production environment you need to follow the standard Android publication process. To build a publishable application, build the container using the command

ant release

This will produce an optimized and obfuscated .apk file, that must be signed before publishing the application. Signing is achieved using standard the Android signing process.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© Copyright 2016 ICEsoft Technologies Canada Corp.