예제 #1
0
 @Override
 protected UserData doInBackground(UserData... params) {
   try {
     if (params.length > 0) {
       UserData d = params[0];
       LoginRequest rq =
           new LoginRequest(
               d.getUserName(), d.getPassword(), getText(R.string.loginEndPoint).toString());
       LoginResponse response = m_ServiceInterface.requestLogin(rq);
       return new UserData(
           response.getUserName(), d.getPassword(), response.getUserID(), response.getUUID());
     } else return new UserData("", "", -1, null);
   } catch (Exception e) {
     return new UserData("", "", -1, null);
   }
 }
예제 #2
0
 @Override
 protected void onPostExecute(UserData result) {
   try {
     m_UserData = result;
     if (m_UserData.getUserID() >= 0) {
       Intent intent = new Intent(LoginActivity.this, GameListActivity.class);
       intent.putExtra("UserData", m_UserData);
       // this is a horribly insecure way of saving credentials.
       SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
       SharedPreferences.Editor editor = settings.edit();
       editor.putString("username", result.getUserName());
       editor.putString("password", result.getPassword());
       editor.commit();
       startActivity(intent);
     } else setStatus("Login Failed.");
   } catch (Exception ex) {
     setStatus("Login Failed.");
   }
 }