Get main gmail account status

1k Views Asked by At

I am developing an Android application and I need to know status of the Google account used on the phone. I want to do this for the C2DM, but I don't want to ask the user to login again in his/her Google email account if they are already logged in. Is there any way to do it?

I already know hot to get the Google account..

Account[] accts = accountManager.getAccountsByType("com.google"); 
Account acct = accts[0]; 
System.out.println("Account:"+acct.name);

But how to check the status (logged_out, logging_in or logged_in)?

Thanks.

2

There are 2 best solutions below

0
On BEST ANSWER

I haven't been able to find a way to do exactly what you're looking for, but one simple solution would be to ask the user for their credentials when they first access the app (or this portion of the app) and then store them to use for future use. This way you can still check it without prompting them for their credentials and it won't matter what their current login state is.

0
On

What I know is if thru AccountManager u r getting the Email Id Id then it is logged in....That's what u were asking or something else and I misunderstood it......