हाय ग्रहण कर रही मैं अपने authToken उबरने जब मैं फोनएंड्रॉयड खाता प्रबंधक authToken
mAccountManager.blockingGetAuthToken(Auth.getAccount(), Auth.AUTH_TOKEN_TYPE, true)
मैं एक अशक्त स्ट्रिंग वापस पाने, जो मुझे नेतृत्व, विशेष रूप से मेरी AbstractAccountAuthenticator वर्ग में देखना समस्याएं आ रही हैं getAuth()।
public Bundle getAuthToken(AccountAuthenticatorResponse response,
Account account, String authTokenType, Bundle options)
throws NetworkErrorException {
final AccountManager am = AccountManager.get(mContext);
String authToken = am.peekAuthToken(account, authTokenType);
String uid = am.getUserData(account, AccountManager.KEY_CALLER_UID);
// return bundle with authToken
if (!TextUtils.isEmpty(authToken)) {
final Bundle result = new Bundle();
result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);
result.putString(AccountManager.KEY_AUTHTOKEN, authToken);
result.putString(AccountManager.KEY_CALLER_UID, uid);
return result;
}
return null;
}
peekAuthToken एक अशक्त लौट जाता है, तथापि मैं सही uid
getUserData से जो मुझे नेतृत्व मैं खाता ठीक द्वारा जोड़ा जा रहा विश्वास करने के लिए हो रही है: यहाँ क्या अपने कर रहा है। इस प्रकार मैंने ऑथोकन सेट किया है:
mAccountManager.addAccountExplicitly(account, accountPassword, extraData);
//The addAccount is working, and I can obtain the extraData in getAuth
mAccountManager.setAuthToken(account, Auth.AUTH_TOKEN_TYPE, authtoken);
//I assume this is where the authToken is to be cached…but I can't retrieve it…
//The token does exist at this point
कोई सुझाव?
आप खाते चर पारित हो कि कि एक जब आप setAuthToken फोन के रूप में ही है यकीन है? – CChi
मैं इतना विश्वास है, Auth.getAccount() रिटर्न AccountManager.get (App.getContext()) getAccountsByType (ACCOUNT_TYPE) [0]। और यह – AIntel
खाते के बारे में जानकारी सही ढंग से रखता है, मैं वास्तव में यह पता नहीं लगा सकता कि इस कोड खंड को देखकर क्या होता है। लेकिन आप खाता प्रबंधक के पूर्ण कवरेज के लिए यह लिंक देख सकते हैं। http://udinic.wordpress.com/2013/04/24/write-your-own-android-authenticator/ – CChi