I'm trying to create an application that uses a Gmail account to send emails automatically.
I do not want that the user enters username and password if he has already added a Gmail account in his Android Device, but I want the application uses that account to send email automatically.
I already know how to get the username and password but when I ask for the password I get the following error:
02-14 10:53:40.660: E/AndroidRuntime(23719): Caused by: java.lang.SecurityException: caller uid xxxxx is different than the authenticator's uid
Where xxxxx is the UID number. My code is this:
AccountManager manager = AccountManager.get(this);
Account[] accounts = manager.getAccountsByType("com.google");
for (Account account : accounts){
if(account.name.endsWith("gmail.com")){
String gmailAddress = account.name;
String password = manager.getPassword(account);
}
}
Please give my an example code or a link to read it. Don't give me anything else. Many Thaks