Tôi đang thử nghiệm với Android AccountManager
.SecurityException khi cố gắng thêm tài khoản
Tôi có dịch vụ xác thực tài khoản hiển thị giao diện người dùng để nhập tên người dùng/mật khẩu.
Tôi chuyển đến Cài đặt/Tài khoản/Thêm tài khoản, chọn loại tài khoản mới của tôi và tôi được trình bày với giao diện người dùng.
Khi tôi bấm vào OK tôi nhận được lỗi sau
04-24 14:48:29.334: E/AndroidRuntime(386): java.lang.SecurityException:
caller uid 10035 is different than the authenticator's uid
Phương pháp duy nhất của MyAccountAuthenticationService:
@Override
public IBinder onBind(Intent intent) {
return new MyAccountAuthenticator(this).getIBinder();
}
MyAccountAuthenticator:
@Override
public Bundle addAccount(AccountAuthenticatorResponse response,
String accountType, String authTokenType, String[] requiredFeatures,
Bundle options) throws NetworkErrorException {
final Intent intent = new Intent(context, MyAccountCreatorActivity.class);
intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
final Bundle bundle = new Bundle();
bundle.putParcelable(AccountManager.KEY_INTENT, intent);
return bundle;
}
Fragment của MyAccountCreatorActivity
's onClick
AccountManager accManager = AccountManager.get(this);
Account newAccount = new Account(email, MyAccountAuthenticator.ACCOUNT_TYPE);
accManager.setPassword(newAccount, password);
Ngoại lệ được ném trên setPassword
. Tôi đã yêu cầu tất cả các quyền kế toán. Tôi không chắc chắn về những gì có thể gây ra điều này. Nếu bạn cần thêm mã/thông tin, vui lòng hỏi.
Cảm ơn bạn.
xem http://loganandandy.tumblr.com/post/613041897/caller-uid-is-different này có thể hữu ích –
Bản sao có thể có của [SecurityException: người gọi uid XXXX khác với xác thực của uid] (http: // stackoverflow.com/questions/3774282/securityexception-caller-uid-xxxx-is-different-than-the-authenticators-uid) – rds
@rds xin lỗi nó không phải là một sự lừa đảo. XML gốc có lỗi đánh máy, tuy nhiên Android sẽ không giải thích chính xác bản chất thực sự của vấn đề –