Advertisement
Guest User

Untitled

a guest
May 25th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. package com.asus.push.service;
  2.  
  3. import android.app.IntentService;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.text.TextUtils;
  7. import android.util.Log;
  8.  
  9. import com.asus.push.analytics.zAnalytics;
  10. import com.asus.push.receiver.zParsePushBroadcastReceiver;
  11. import com.parse.ParseAnalytics;
  12.  
  13. /**
  14. * Created by Ed_Chou on 2015/1/21.
  15. */
  16. public class ProxyService extends IntentService {
  17. public static final String KEY_ACTION_TYPE = "action_type";
  18. public static final String KEY_ACTION_INTENT = "action_intent";
  19. public static final String KEY_PARSE_INTENT = "parse_intent";
  20.  
  21. public static final String TYPE_ACTIVITY = "activity";
  22. public static final String TYPE_SERVICE = "service";
  23. public static final String TYPE_BROADCAST = "broadcast";
  24.  
  25.  
  26. public ProxyService() {
  27. super("ProxyService");
  28. }
  29.  
  30. public static final String TAG = ProxyService.class.getName();
  31.  
  32. @Override
  33. protected void onHandleIntent(Intent intent) {
  34. Log.d(TAG, "onHandleIntent");
  35. Bundle extras = intent.getExtras();
  36. Log.d(TAG, "extras:" + extras);
  37. if (extras != null) {
  38. Log.d(TAG, "extras != null");
  39. zAnalytics.Click(this, intent.getStringExtra(zParsePushBroadcastReceiver.KEY_MESSAGE_ID));
  40. if (extras.containsKey(KEY_ACTION_INTENT)) {
  41. Log.d(TAG, "extrasGetActionIntent");
  42. Intent action = extras.getParcelable(KEY_ACTION_INTENT);
  43. Intent parse_intent = extras.getParcelable(KEY_PARSE_INTENT);
  44. ParseAnalytics.trackAppOpenedInBackground(parse_intent);
  45. action.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  46. String type = extras.getString(KEY_ACTION_TYPE, TYPE_ACTIVITY);
  47. if (TextUtils.equals(type, TYPE_SERVICE)) {
  48. Log.d(TAG, "startService");
  49. startService(action);
  50. } else if (TextUtils.equals(type, TYPE_BROADCAST)) {
  51. Log.d(TAG, "sendBroadcast");
  52. sendBroadcast(action);
  53. } else {
  54. Log.d(TAG, "startActivity");
  55. startActivity(action);
  56. }
  57. }
  58. }
  59.  
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement