Copying SDK and configuration files from the MobileFirst project

To copy the files in the Native API application for Android into the project that defines the native app for Android

About this task

To use the MobileFirst Native API for Android in your native app, you must copy the library and the client property file of your Native API application into your native app for Android project.

Procedure

In your project for the native app for Android:

  1. Copy the worklight-android.jar file, the android-async-http.jar file, the bcprov.jar file, and the uicandroid.jar file from the Native API application, and paste them into the app/libs folder of your native app for Android.
  2. Copy the wlclient.properties client property file from the Native API application into the assets folder of your native app for Android. The assets folder is not created by default. To create the assets folder, right-click the app folder, and select New > Folder > Asset Folder.
  3. If the push notification support is required:
    1. Copy the push.png file from the Native API application.
    2. In the res folder of your native app for Android, identify the folders with a name that starts with drawable (such as res/drawable or res/drawable-ldpi), and then paste the push.png file into each of these folders.
    3. To set up Google Play Services in your Android project, see Adding Google Play services to your Android project.
  4. Add the following lines to the AndroidManifest.xml file of your native app for Android:
    1. <activity android:name="com.worklight.wlclient.ui.UIActivity"/> With this line, a designated MobileFirst UI activity can run in the user application.
    2. <uses-permission android:name="android.permission.INTERNET"/> This line adds Internet access permissions to the user application.
    3. <uses-permission android:name="android.permission.GET_TASKS"/> This line adds the permission to get a list of running tasks that are required for the heartbeat functionality. This permission is required if you are targeting your apps for Android API level 13 and earlier levels.
    4. <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
  5. If push notification support is required, add the following permissions to the AndroidManifest.xml file of your native app for Android:
    1. <uses-permission android:name="com.worklight.androidnativepush.permission.C2D_MESSAGE"/>
    2. <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
    3. <uses-permission android:name="android.permission.WAKE_LOCK"/>
    4. <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
    5. <uses-permission android:name="android.permission.USE_CREDENTIALS"/>
    6. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  6. Optional: If JSONStore is required, copy the contents of the jsonstore/assets/ and jsonstore/libs/ folders into your application's assets/ and libs/ folders, respectively.
  7. Manage your splash screens: In the res folder of your native app for Android, identify the folders with a name that starts with drawable (such as res/drawable or res/drawable-ldpi), and then:
    1. If you want to use a splash screen in your app, you must create a splash.png file or splash.9.png file and place it in each of these folders.
    2. If you do not want to use a splash screen in your app, ensure that no splash.png file or splash.9.png file is present in these folders.
    Note: If you create a hybrid Android app, the splash.9.png file is automatically created. If you do not want to use the splash screen in your app, you must delete it from these drawable folders.
  8. Optional: If app authenticity is required:
    1. Create a new folder jniLibs inside the <project>/src/main/ folder.
    2. Copy the armeabi, armeabi-v7a, mips, and x86 folders (subfolders of the Native API application folder) into the new jniLibs folder. These folders each contain a version of the libauthjni.so file.