private void onCreate ( Context context ) { // The check method fails if: no network connection / app already registered / GooglePlayServices unavailable if ( GcmUtils . checkCanAndShouldRegister ( context ) ) { // Start a background service to register in a background thread context . startService ( GcmRegistrationService . createGcmRegistrationIntent ( context ) ) ; } }
Registers the application defined by a context activity to GCM in case the registration has not been done already . The method can be called anytime but typically at app startup . The registration itself is guaranteed to only run once .