Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onReceive(Context context, Intent intent)
- {
- String action = intent.getAction();
- Log.d(TAG, "Got a reply from Google");
- if (action.equals(REGISTER_ACTION))
- {
- handleRegistration(context, intent);
- }
- else if (action.equals(RECEIVE_ACTION))
- {
- handleMessage(context, intent);
- }
- else
- {
- Log.w(TAG, "Unexpected intent: " + intent);
- }
- }
- private void handleRegistration(Context context, Intent intent)
- {
- String registrationId = intent.getStringExtra("registration_id");
- String error = intent.getStringExtra("error");
- String unregistered = intent.getStringExtra("unregistered");
- if (error != null)
- {
- Log.e(TAG, "Registration failed: " + error);
- this.getApp(context).disablePush();
- }
- else if (unregistered != null)
- {
- Log.d(TAG, "Unregistered: " + unregistered);
- context.startService(new Intent(RegistrationService.COMPLETE_UNREGISTER_ACTION));
- }
- else if (registrationId != null)
- {
- Log.d(TAG, "Registered with registration ID [" + registrationId + "]");
- // Send registrationId to the Application Server in a separate thread.
- Intent i = new Intent(RegistrationService.COMPLETE_REGISTER_ACTION);
- i.putExtra("regId", registrationId);
- context.startService(i);
- }
- else
- {
- Log.d(TAG, "Other registration response: " + intent.getExtras());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment