2015-12-22 27 views
0

我做了一個非常標準的解析註冊以下在線文檔。除此之外,我試圖在用戶註冊後通過調用SignUpCallback的done(ParseUser user, ParseException e)方法中的logInInBackground來實現自動登錄。ParseUser.signUpInBackground永不「完成」

user.signUpInBackground(new SignUpCallback() { 

     public void done(ParseException e) { 
      if (e == null) { 
       // Hooray! Now sign in with the account that has just been created 
       ParseUser.logInInBackground(uname, pw, new LogInCallback() { 
        public void done(ParseUser user, ParseException e) { 
         if (user != null) { 
          Log.d("DONE SIGNUP", "STRANGE"); 
          // Hooray! The user is logged in. 
          // Associate this user with this device 
          ParseInstallation curIns = ParseInstallation.getCurrentInstallation(); 
          curIns.put("username", user.getUsername()); 
          curIns.saveInBackground(); 
          alertMsg.setText("Signed In"); 
          //Go to the usermainpage activity 
          Intent mainP = new Intent(ACTLoginSelf.this, ACTRequest.class); 
          startActivity(mainP); 



         } else { 
          // Signup failed. Look at the ParseException to see what happened. =======TBD========= 
          alertMsg.setText("Missing information, cannot proceed! " + e.getMessage()); 
         } 
        } 
       }); 
      } else { 
       // Sign up didn't succeed. Look at the ParseException 
       // to figure out what went wrong 
       //report is there are duplicate accounts existing and such! ============TBD============ 
      } 
     } 
    }); 

我不知道爲什麼signUpInBackground似乎永遠是「完成」,而新的條目從未被填充到分析用戶數據庫。是否因爲我嘗試實現自動登錄?我確信,在標誌中加入Log.d的地方開始,

12-22 14:39:09.210 1570-1570/com.android.inputmethod.latin I/LatinIME: Starting input. Cursor position = 0,0 
12-22 14:39:19.033 26189-26189/com.parse.starter D/SIGNING UP: PLEASE WAIT 

但它似乎只是沒有完成。

謝謝!

回答

0

甚至不打擾登錄。註冊時,默認情況下,用戶通過註冊的Android客戶端登錄。

您可以訪問登錄的用戶,如下所示:

ParseUser user = ParseUser.getCurrentUser(); 

無需註冊後登錄。

編輯:事實上,用戶堅持登錄,直到他們清除緩存或應用程序被卸載。 (或者當然如果你使用Parse SDK以編程方式註銷)

+0

謝謝,我刪除登錄後,它完成得很快。但是,它完成了一個錯誤:無法註冊已註冊的用戶。 有趣的是,我以前沒有註冊過這個用戶。你知道我爲什麼會得到這個錯誤嗎?我會在上面更新我的代碼。謝謝,@lucas – user3685578

+0

你是否按了兩次按鈕?或者以您開始註冊的方式?鏈接完整的堆棧跟蹤 –

+0

嘗試卸載應用程序,並嘗試新的我建議的更改 –