Source:
<code>protected void onPostExecute(String result) { String refreshToken = null; String accessToken = null; int timeToExpireSecond = 3000; IdentityProxy identityProxy = IdentityProxy.getInstance(); try { JSONObject response = new JSONObject(result); Log.e("refresh Token Post", result.toString()); if (responseCode != null && responseCode.equals("200")) { refreshToken = response.getString("refresh_token"); accessToken = response.getString("access_token"); timeToExpireSecond = Integer.parseInt(response.getString("expires_in")); token.setRefreshToken(refreshToken); token.setAccessToken(accessToken); SharedPreferences mainPref = IdentityProxy.getInstance() .getContext() .getSharedPreferences("com.mdm", Context.MODE_PRIVATE); Editor editor = mainPref.edit(); editor.putString("refresh_token", refreshToken); editor.putString("access_token", accessToken); DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); Date date = new Date(); long expiresIN = date.getTime() + (timeToExpireSecond * 1000); Date expireDate = new Date(expiresIN); String strDate = dateFormat.format(expireDate); token.setDate(strDate); editor.putString("date", strDate); editor.commit(); identityProxy.receiveNewAccessToken(responseCode, "success", token); } else if (responseCode != null) { JSONObject mainObject = new JSONObject(result); String error = mainObject.getString("error"); String errorDescription = mainObject.getString("error_description"); Log.d(TAG, error); Log.d(TAG, errorDescription); identityProxy.receiveNewAccessToken(responseCode, errorDescription, token); } } catch (JSONException e) { identityProxy.receiveNewAccessToken(responseCode, "", token); <START> e.printStackTrace(); <END> } }</code><technical_language>Need get rid of printing stacktraces. Instead proper logging exception handling catch block</technical_language>

Target:
protected void onPostExecute(String result) { String refreshToken = null; String accessToken = null; int timeToExpireSecond = 3000; IdentityProxy identityProxy = IdentityProxy.getInstance(); try { JSONObject response = new JSONObject(result); if (responseCode != null && responseCode.equals(Constants.REQUEST_SUCCESSFUL)) { refreshToken = response.getString(Constants.REFRESH_TOKEN); accessToken = response.getString(Constants.ACCESS_TOKEN); timeToExpireSecond = Integer.parseInt(response.getString(Constants.EXPIRE_LABEL)); token.setRefreshToken(refreshToken); token.setAccessToken(accessToken); SharedPreferences mainPref = IdentityProxy.getInstance() .getContext() .getSharedPreferences(Constants.APPLICATION_PACKAGE, Context.MODE_PRIVATE); Editor editor = mainPref.edit(); editor.putString(Constants.REFRESH_TOKEN, refreshToken); editor.putString(Constants.ACCESS_TOKEN, accessToken); Date date = new Date(); long expiresIN = date.getTime() + (timeToExpireSecond * 1000); Date expireDate = new Date(expiresIN); String strDate = dateFormat.format(expireDate); token.setDate(strDate); editor.putString(Constants.DATE_LABEL, strDate); editor.commit(); identityProxy .receiveNewAccessToken(responseCode, Constants.SUCCESS_RESPONSE, token); } else if (responseCode != null) { JSONObject responseBody = new JSONObject(result); String errorDescription = responseBody.getString(Constants.ERROR_DESCRIPTION_LABEL); identityProxy.receiveNewAccessToken(responseCode, errorDescription, token); } } catch (JSONException e) { identityProxy.receiveNewAccessToken(responseCode, null, token); Log.e(TAG, "Invalid JSON." + e); } }