Advertisement
Guest User

Untitled

a guest
Mar 27th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1.  
  2.     public static class getSessionId extends AsyncTask<Void, Void, String>
  3.     {
  4.         private String user;
  5.         private String password;
  6.         private LoginAttemptedCallback loginAttemptedCallback;
  7.  
  8.         public getSessionId(String user, String password, LoginAttemptedCallback loginAttemptedCallback)
  9.         {
  10.             this.loginAttemptedCallback = loginAttemptedCallback;
  11.             this.user = user;
  12.             this.password = password;
  13.         }
  14.  
  15.         @Override
  16.         protected String doInBackground(Void... params)
  17.         {
  18.             return getSessionId(user, password);
  19.         }
  20.  
  21.         @Override
  22.         protected void onPostExecute(String result)
  23.         {
  24.             Log.d("TAG", "Session id: " + result);
  25.  
  26.             try
  27.             {
  28.                 JSONObject results = new JSONObject(result);
  29.                 String sessionId = results.getString("session_id");
  30.                 if (sessionId != null)
  31.                 {
  32.                     loginAttemptedCallback.onLoginSuccess(user, password, sessionId);
  33.                 }
  34.             } catch (JSONException e)
  35.             {
  36.                 loginAttemptedCallback.onLoginFailed();
  37.             }
  38.         }
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement