diff --git a/app/src/main/java/org/flyve/mdm/agent/core/enrollment/EnrollmentHelper.java b/app/src/main/java/org/flyve/mdm/agent/core/enrollment/EnrollmentHelper.java index f8db4e9c02..90d84ff0dc 100644 --- a/app/src/main/java/org/flyve/mdm/agent/core/enrollment/EnrollmentHelper.java +++ b/app/src/main/java/org/flyve/mdm/agent/core/enrollment/EnrollmentHelper.java @@ -136,11 +136,12 @@ public void run() { } JSONObject jsonSession = new JSONObject(data); - cache.setSessionToken(jsonSession.getString("session_token")); + final String sessionToken = jsonSession.getString("session_token"); + cache.setSessionToken(sessionToken); // STEP 2 get full session information HashMap header = new HashMap(); - header.put(SESSION_TOKEN, cache.getSessionToken()); + header.put(SESSION_TOKEN, sessionToken); header.put(ACCEPT,APPLICATION_JSON); header.put(CONTENT_TYPE,APPLICATION_JSON + ";" + CHARSET); header.put(USER_AGENT,FLYVE_MDM); @@ -164,7 +165,7 @@ public void run() { cache.setProfileId(profileId); // STEP 3 Activated the profile - final String dataActiveProfile = getSyncWebData(routes.changeActiveProfile(cache.getProfileId()), "POST", header); + final String dataActiveProfile = getSyncWebData(routes.changeActiveProfile(profileId), "POST", header); final String errorActiveProfile = manageError(dataActiveProfile); if(!errorActiveProfile.equals("")) { EnrollmentHelper.runOnUI(new Runnable() { @@ -176,7 +177,7 @@ public void run() { // Success EnrollmentHelper.runOnUI(new Runnable() { public void run() { - callback.onSuccess(cache.getSessionToken()); + callback.onSuccess(sessionToken); } }); }