尝试从客户经理处获取 Gmail 用户名和密码时,出现以下异常:
java.lang.SecurityException: caller uid 10073
与验证者的 uid 不同
AccountManager accountManager = AccountManager.get(mContex);
Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
Account[] accounts = AccountManager.get(mContex).getAccounts();
for (Account account : accounts) {
if (emailPattern.matcher(account.name).matches()) {
String possibleEmail = account.name;
String possiblePassword = accountManager.getPassword(account) ;
System.out.println("User name :- "+possibleEmail);
System.out.println("User Password :- "+possiblePassword);
}
}
在 Manifest.xml 中添加了权限:
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.GET_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.USE_CREDENTIALS"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
关于如何解决此异常的任何想法?