Search code examples
androidandroid-intentandroid-c2dmgoogle-cloud-messaging

New Google account added broadcast


I am working on GCM implementation for our Application. Currently I am facing a issue during GCM registration.

If the device is running pre-ICS Android OS and does not have a Google account attached with the device, GCM server sends a "Account_Missing" error back to Receiver. I am handling this case by notifying the user to add a new Google account. But the problem is, Application will never know if a new Google account is added until the application is re-logged in.

In normal scenario - as soon as the application receives a GCM registration id it sends that reg id to the app server. I want to initiate the GCM registration process as soon as application gets first Google account added broadcast and the registration id to the app server automatically. Now, I know what have to do, but I don't know if there is any such broadcast or is there any other way to achieve the same expected behavior.


Solution

  • Please Look at this http://developer.android.com/reference/android/accounts/AccountManager.html#addOnAccountsUpdatedListener%28android.accounts.OnAccountsUpdateListener,%20android.os.Handler,%20boolean%29 this and handle the account addition.

    Hope that helps !