Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class getSessionId extends AsyncTask<Void, Void, String>
- {
- private String user;
- private String password;
- private LoginAttemptedCallback loginAttemptedCallback;
- public getSessionId(String user, String password, LoginAttemptedCallback loginAttemptedCallback)
- {
- this.loginAttemptedCallback = loginAttemptedCallback;
- this.user = user;
- this.password = password;
- }
- @Override
- protected String doInBackground(Void... params)
- {
- return getSessionId(user, password);
- }
- @Override
- protected void onPostExecute(String result)
- {
- Log.d("TAG", "Session id: " + result);
- try
- {
- JSONObject results = new JSONObject(result);
- String sessionId = results.getString("session_id");
- if (sessionId != null)
- {
- loginAttemptedCallback.onLoginSuccess(user, password, sessionId);
- }
- } catch (JSONException e)
- {
- loginAttemptedCallback.onLoginFailed();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement