Folk, I'm still testing IBM MobileFirst Platform 8.0. Today it's time to add the MobileFirst SDK to Android Applications.
I will follow once again the guide documented in the development site of IBM MobileFirst Platform.
Hope that helps!
Let's go, the dependencies correspond to core functions and other functions:
1. Create an Android Studio project or use an existing one
2. In Android → Gradle Scripts, select the build.gradle (Module: app) file
3. Add the following lines after apply plugin: 'com.android.application':
repositories{
jcenter()
}
4. Add the following line inside the android section:
packagingOptions {
pickFirst 'META-INF/ASL2.0'
pickFirst 'META-INF/LICENSE'
pickFirst 'META-INF/NOTICE'
}
5. Add the following line inside the dependencies section:
compile 'com.ibm.mobile.foundation:ibmmobilefirstplatformfoundation:8.0.+'
6. In Android → app → manifests, open the AndroidManifest.xml file. Add the following permissions above the application element:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
7. Add the MobileFirst UI activity next to the existing activity element:
<activity android:name="com.worklight.wlclient.ui.UIActivity" />
Note: If a Gradle Sync request appears, accept it.
8. Registering the application to MobileFirst Server, go to project folder and run:
$ mfpdev app register
Verifying server configuration...
Registering to server:'http://###.###.###.###:9080' runtime:'mfp'
Registered app for platform: android
Note: To check the registration in the console, in this example I have installed the MobileFirst Server component in my local environment: http://localhost:9080/mfpconsole/login.html
9. Creating a WLClient instance, in this example, added in MainActivity class.
WLClient.createInstance(this);
Note: Creating a WLClient instance should happen only once in the entire application lifecycle. It is recommended to use the Android Application class to do it.
10. Run the app in Run → Run 'app'
Cheers!!!
I will follow once again the guide documented in the development site of IBM MobileFirst Platform.
Hope that helps!
Let's go, the dependencies correspond to core functions and other functions:
- IBMMobileFirstPlatformFoundation - Implements client-to-server connectivity, handles authentication and security aspects, resource requests, and other required core functions
- IBMMobileFirstPlatformFoundationJSONStore - Contains the JSONStore framework
- IBMMobileFirstPlatformFoundationPush - Contains the Push Notifications framework
- Android Studio and MobileFirst CLI installed on the developer workstation
- A local or remote instance of MobileFirst Server is running
- Setting up your MobileFirst development environment and Setting up your Android development environment
1. Create an Android Studio project or use an existing one
2. In Android → Gradle Scripts, select the build.gradle (Module: app) file
3. Add the following lines after apply plugin: 'com.android.application':
repositories{
jcenter()
}
4. Add the following line inside the android section:
packagingOptions {
pickFirst 'META-INF/ASL2.0'
pickFirst 'META-INF/LICENSE'
pickFirst 'META-INF/NOTICE'
}
5. Add the following line inside the dependencies section:
compile 'com.ibm.mobile.foundation:ibmmobilefirstplatformfoundation:8.0.+'
6. In Android → app → manifests, open the AndroidManifest.xml file. Add the following permissions above the application element:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
7. Add the MobileFirst UI activity next to the existing activity element:
<activity android:name="com.worklight.wlclient.ui.UIActivity" />
8. Registering the application to MobileFirst Server, go to project folder and run:
$ mfpdev app register
Verifying server configuration...
Registering to server:'http://###.###.###.###:9080' runtime:'mfp'
Registered app for platform: android
Note: To check the registration in the console, in this example I have installed the MobileFirst Server component in my local environment: http://localhost:9080/mfpconsole/login.html
9. Creating a WLClient instance, in this example, added in MainActivity class.
WLClient.createInstance(this);
Note: Creating a WLClient instance should happen only once in the entire application lifecycle. It is recommended to use the Android Application class to do it.
10. Run the app in Run → Run 'app'
Cheers!!!
No comments:
Post a Comment