For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.


Updating the Android code

MobileFirstV8.0.0 introduces a number of changes to the Android SDK that might require changes to apps developed in earlier versions.

The tables below list changes in the MobileFirst Android SDK.

For some sample code for creating the client and accessing the server with the new V8.0.0 client for Android, see Some initial code for accessing the server.

Table 1. Discontinued Android API elements
API element Migration path
WLConfig WLClient.getConfig() No replacement.

WLDevice WLClient.getWLDevice()

WLClient.transmitEvent(org.json.JSONObject event)

WLClient.setEventTransmissionPolicy(WLEventTransmissionPolicy policy)

WLClient.purgeEventTransmissionBuffer()

Use Android API or third-party packages for GeoLocation.
WL.Client.getUserInfo(realm, key)

WL.Client.updateUserInfo(options)

No replacement.
WL.Client.getUserInfo(realm, key

WL.Client.updateUserInfo(options)

No replacement
WLClient.checkForNotifications() Use WLAuthorizationManager.obtainAccessToken("", listener) to check connectivity to the server and apply application management rules.
WLClient.login(java.lang.String realmName, WLRequestListener listener, WLRequestOptions options)

WLClient.login(java.lang.String realmName, WLRequestListener listener)

Use AuthorizationManager.login()
WLClient.logout(java.lang.String realmName, WLRequestListener listener, WLRequestOptions options)

WLClient.logout(java.lang.String realmName, WLRequestListener listener)

Use AuthorizationManager.logout().
WLClient.obtainAccessToken(java.lang.String scope,WLResponseListener responseListener) Use WLAuthorizationManager.obtainAccessToken(String, WLAccessTokenListener) to check connectivity to the server and apply application management rules.
WLClient.getLastAccessToken()

WLClient.getLastAccessToken(java.lang.String scope)

Use AuthorizationManager.
WLClient.getRequiredAccessTokenScope(int status, java.lang.String header) Use AuthorizationManager.
WLClient.logActivity(java.lang.String activityType) Use com.worklight.common.Logger . For more information, see Logger SDK.
WLAuthorizationPersistencePolicy No replacement. To implement authorization persistence, store the authorization token in the application code and create custom HTTP requests. For more information, see Java™ custom resource-request implementation sample.
WLSimpleSharedData.setSharedToken(myName, myValue)

WLSimpleSharedData.getSharedToken(myName)

WLSimpleSharedData.clearSharedToken(myName)

Use the Android APIs to share tokens across applications.
WLUserCertificateManager.deleteCertificate(android.content.Context context) No replacement
BaseChallengeHandler.submitFailure(WLResponse wlResponse) Use BaseChallengeHandler.cancel().
ChallengeHandler For custom gateway challenges, use GatewayChallengeHandler. For MobileFirst security-check challenges, use SecurityCheckChallengeHandler. For more information about the V8.0.0 challenge-handler APIs, see Client security APIs.
WLChallengeHandler Use SecurityCheckChallengeHandler. For more information about the V8.0.0 challenge-handler APIs, see Client security APIs.
ChallengeHandler.isCustomResponse() Use GatewayChallengeHandler.canHandleResponse().
ChallengeHandler.submitAdapterAuthentication Implement similar logic in your challenge handler. For custom gateway challenge handlers, use GatewayChallengeHandler. For MobileFirst security-check challenge handlers, use SecurityCheckChallengeHandler.

Table 2. Android APIs depending on the legacy org.apach.http APIs are no longer supported
API element Migration path
org.apache.http.Header[] is now deprecated. Therefore, the following methods are removed:  

org.apache.http.Header[] WLResourceRequest.getAllHeaders()

Use instead the new Map<String, List<String>> WLResourceRequest.getAllHeaders() API.

WLResourceRequest.addHeader(org.apache.http.Header header)

Use instead the new WLResourceRequest.addHeader(String name, String value) API.

org.apache.http.Header[] WLResourceRequest.getHeaders(java.lang.String headerName)

Use instead the new List<String> WLResourceRequest.getHeaders(String headerName) API.

org.apache.http.Header WLResourceRequest.getFirstHeader(java.lang.String headerName)

Use instead the new WLResourceRequest.getHeaders(String headerName) API.

WLResourceRequest.setHeaders(org.apache.http.Header[] headers)

Instead, use the new WLResourceRequest.setHeaders(Map<String, List<String>> headerMap) API.

WLResourceRequest.setHeader(org.apache.http.Header header)

Instead, use the new WLResourceRequest.setHeaders(Map<String, List<String>> headerMap) API.
org.apache.http.client.CookieStore WLClient.getCookieStore() Replaced with java.net.CookieStore getCookieStore WLClient.getCookieStore()

java.net.CookieStore getCookieStore WLClient.getCookieStore()

WLClient.setAllowHTTPClientCircularRedirect(boolean isSet) No replacement. MFP Client allows circular redirects.

WLHttpResponseListener WLResourceRequest, all methods that take WLHttpResponseListener:

WLResourceRequest.send(java.util.HashMap formParameters,WLHttpResponseListener listener)

WLResourceRequest.send(org.json.JSONObject json, WLHttpResponseListener listener)

WLResourceRequest.send(byte[] data, WLHttpResponseListener listener)

WLResourceRequest.send(java.lang.String requestBody,WLHttpResponseListener listener)

WLResourceRequest.send(WLHttpResponseListener listener)

WLClient.sendRequest(org.apache.http.client.methods.HttpUriRequest request,WLHttpResponseListener listener)

WLClient.sendRequest(org.apache.http.client.methods.HttpUriRequest request, WLResponseListener listener)

Removed due to deprecated Apache HTTP Client dependencies. Create your own request to have full control over the request and response.

Parent topic: Migrating existing native Android applications