Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.wmakit.samataxi.gcm;
- import android.app.IntentService;
- import android.app.Notification;
- import android.app.NotificationChannel;
- import android.app.NotificationManager;
- import android.app.PendingIntent;
- import android.content.Context;
- import android.content.Intent;
- import android.graphics.BitmapFactory;
- import android.media.Ringtone;
- import android.media.RingtoneManager;
- import android.net.Uri;
- import android.os.Build;
- import android.os.Bundle;
- import android.os.Vibrator;
- import android.support.v4.app.NotificationCompat;
- import android.support.v4.content.LocalBroadcastManager;
- import android.util.Log;
- import android.widget.Toast;
- import com.google.android.gms.gcm.GcmListenerService;
- import com.wmakit.samataxi.R;
- import com.wmakit.samataxi.RequestService;
- import com.wmakit.samataxi.activities.NotificationActivity;
- import com.wmakit.samataxi.activities.SplashActivity;
- import com.wmakit.samataxi.activities.WaitDriverConfirmActivity;
- import com.wmakit.samataxi.config.Constant;
- import com.wmakit.samataxi.config.GlobalValue;
- import com.wmakit.samataxi.config.PreferencesManager;
- import com.wmakit.samataxi.modelmanager.ModelManager;
- import com.wmakit.samataxi.modelmanager.ModelManagerListener;
- import com.wmakit.samataxi.modelmanager.ParseJsonUtil;
- import com.wmakit.samataxi.object.CurrentOrder;
- import com.wmakit.samataxi.service.LaunchAnswerCallActivityService;
- import com.wmakit.samataxi.volleynetwork.ControllerRequest;
- import org.json.JSONException;
- import org.json.JSONObject;
- import java.util.Random;
- import static android.app.Notification.CATEGORY_CALL;
- import static com.wmakit.samataxi.config.Constant.ECO_SUB_TYPE_DELIVERY;
- import static com.wmakit.samataxi.config.Constant.KEY_ADDITIONAL_DISTANCE;
- import static com.wmakit.samataxi.config.PreferencesManager.ECO_SUB_TYPE;
- /**
- * {@link IntentService} responsible for handling GCM messages.
- */
- public class GCMIntentService extends GcmListenerService {
- private final String TAG = "GCMIntentService";
- public static final String KEY_DATA = "data";
- public static final String KEY_BODY = "body";
- public static final String KEY_ACTION = "action";
- private static int NOTIFICATION_ID = 0;
- private static int NOTIFICATION_HEAD_ID = 1000;
- private static String NOTIFICATION_CHANEL_ID = "chanel_01";
- private static String NOTIFICATION_CHANEL_NAME = "Alerte";
- private PreferencesManager preferencesManager = PreferencesManager
- .getInstance(this);
- @Override
- public void onMessageReceived(String from, Bundle data) {
- Log.e(TAG, "onMessage: " + data);
- processReciverPush(this, data);
- }
- private void processReciverPush(Context context, Bundle data) {
- String action = data.getString(KEY_ACTION);
- Log.e(TAG, "onMessage action: " + action);
- Intent broadCastIntent;
- if (null == action) {
- return;
- }
- switch (action) {
- // Done
- case Constant.ACTION_CALL_RECEIVED:
- try {
- JSONObject jsonObject = new JSONObject(data.getString(KEY_DATA));
- Log.e(TAG, "onMessage gcm: " + jsonObject.getString("userName"));
- Intent intent = new Intent(this, LaunchAnswerCallActivityService.class);
- intent.putExtra("id", jsonObject.getString("id"));
- intent.putExtra("userName", jsonObject.getString("userName"));
- intent.putExtra("image", jsonObject.getString("image"));
- intent.putExtra("phone", jsonObject.getString("phone"));
- startService(intent);
- } catch (Exception e) {
- e.printStackTrace();
- }
- break;
- case Constant.NOTIFY_PARTENER_SINCH_CALL_HANGUP:
- broadCastIntent = new Intent();
- broadCastIntent.setAction(Constant.NOTIFY_PARTENER_SINCH_CALL_HANGUP);
- sendBroadcast(broadCastIntent);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement