Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.asus.push.service;
- import android.app.IntentService;
- import android.content.Intent;
- import android.os.Bundle;
- import android.text.TextUtils;
- import android.util.Log;
- import com.asus.push.analytics.zAnalytics;
- import com.asus.push.receiver.zParsePushBroadcastReceiver;
- import com.parse.ParseAnalytics;
- /**
- * Created by Ed_Chou on 2015/1/21.
- */
- public class ProxyService extends IntentService {
- public static final String KEY_ACTION_TYPE = "action_type";
- public static final String KEY_ACTION_INTENT = "action_intent";
- public static final String KEY_PARSE_INTENT = "parse_intent";
- public static final String TYPE_ACTIVITY = "activity";
- public static final String TYPE_SERVICE = "service";
- public static final String TYPE_BROADCAST = "broadcast";
- public ProxyService() {
- super("ProxyService");
- }
- public static final String TAG = ProxyService.class.getName();
- @Override
- protected void onHandleIntent(Intent intent) {
- Log.d(TAG, "onHandleIntent");
- Bundle extras = intent.getExtras();
- Log.d(TAG, "extras:" + extras);
- if (extras != null) {
- Log.d(TAG, "extras != null");
- zAnalytics.Click(this, intent.getStringExtra(zParsePushBroadcastReceiver.KEY_MESSAGE_ID));
- if (extras.containsKey(KEY_ACTION_INTENT)) {
- Log.d(TAG, "extrasGetActionIntent");
- Intent action = extras.getParcelable(KEY_ACTION_INTENT);
- Intent parse_intent = extras.getParcelable(KEY_PARSE_INTENT);
- ParseAnalytics.trackAppOpenedInBackground(parse_intent);
- action.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- String type = extras.getString(KEY_ACTION_TYPE, TYPE_ACTIVITY);
- if (TextUtils.equals(type, TYPE_SERVICE)) {
- Log.d(TAG, "startService");
- startService(action);
- } else if (TextUtils.equals(type, TYPE_BROADCAST)) {
- Log.d(TAG, "sendBroadcast");
- sendBroadcast(action);
- } else {
- Log.d(TAG, "startActivity");
- startActivity(action);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement