Guest User

Untitled

a guest
Jul 13th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. @Override
  2. public void onReceive(Context context, Intent intent)
  3. {
  4. String action = intent.getAction();
  5. Log.d(TAG, "Got a reply from Google");
  6. if (action.equals(REGISTER_ACTION))
  7. {
  8. handleRegistration(context, intent);
  9. }
  10. else if (action.equals(RECEIVE_ACTION))
  11. {
  12. handleMessage(context, intent);
  13. }
  14. else
  15. {
  16. Log.w(TAG, "Unexpected intent: " + intent);
  17. }
  18. }
  19.  
  20.  
  21. private void handleRegistration(Context context, Intent intent)
  22. {
  23. String registrationId = intent.getStringExtra("registration_id");
  24. String error = intent.getStringExtra("error");
  25. String unregistered = intent.getStringExtra("unregistered");
  26. if (error != null)
  27. {
  28. Log.e(TAG, "Registration failed: " + error);
  29. this.getApp(context).disablePush();
  30. }
  31. else if (unregistered != null)
  32. {
  33. Log.d(TAG, "Unregistered: " + unregistered);
  34. context.startService(new Intent(RegistrationService.COMPLETE_UNREGISTER_ACTION));
  35. }
  36. else if (registrationId != null)
  37. {
  38. Log.d(TAG, "Registered with registration ID [" + registrationId + "]");
  39. // Send registrationId to the Application Server in a separate thread.
  40. Intent i = new Intent(RegistrationService.COMPLETE_REGISTER_ACTION);
  41. i.putExtra("regId", registrationId);
  42. context.startService(i);
  43. }
  44. else
  45. {
  46. Log.d(TAG, "Other registration response: " + intent.getExtras());
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment