@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /* * Filter messages based on message type. Since it is likely that GCM * will be extended in the future with new message types, just ignore * any message types you're not interested in, or that you don't * recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { System.out.println(extras.toString()); // Game Logic // if we are on the correct page with correct opponent, update UI Intent responseIntent = new Intent("com.jajmu.GOT_PUSH"); responseIntent.putExtras(extras); sendOrderedBroadcast(responseIntent, null); // otherwise send notification // sendNotification(extras); // int duration = Toast.LENGTH_SHORT; // Toast toast = Toast.makeText(getApplicationContext(), extras.toString(), duration); // toast.show(); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { try { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); sf = getSharedPreferences(Constants.UserInfoSharedPref, MODE_PRIVATE); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { Article article = new Article( Integer.parseInt(extras.getString("id")), extras.getString("name"), extras.getString("email"), extras.getString("title"), Integer.parseInt(extras.getString("category")), Long.parseLong(extras.getString("timestamp")), extras.getInt("publisher")); if (sf.getBoolean(Constants.SignInDone, false)) { sendNotification(article); } } } GcmBroadcastReceiver.completeWakefulIntent(intent); } catch (Exception ex) { ex.printStackTrace(); } }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { for (int i = 0; i < 3; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(5000); } catch (InterruptedException e) { } } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); sendNotification( "Message Received from Google GCM Server: " + extras.get(Config.MESSAGE_KEY)); Log.i(TAG, "Received: " + extras.toString()); } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /* * Filter messages based on message type. Since it is likely that GCM * will be extended in the future with new message types, just ignore * any message types you're not interested in, or that you don't * recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // This loop represents the service doing some work. String time = intent.getStringExtra("time"); sendNotification("Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { if (!isAppActive()) { sendNotification(getString(R.string.got_message)); } // Release the wake lock provided by the WakefulBroadcastReceiver GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { extras = intent.getExtras(); String value = extras.getString("message"); Log.i(TAG, "Bundle 'message' Value = " + value); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); Log.i(TAG, "in gcm intent Message = " + messageType); Log.i(TAG, "in gcm intent Message Bundle = " + extras.toString()); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /* * Filter messages based on message type. Since it is likely that GCM * will be extended in the future with new message types, just ignore * any message types you're not interested in, or that you don't * recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // String received_message=intent.getStringExtra("text_message"); String received_message = extras.getString("message"); Log.i(TAG, "received_message = " + received_message); if (received_message.equalsIgnoreCase("track")) { Log.i(TAG, "In if block, received_message = " + received_message); Intent i = new Intent(this, DemoLocation.class); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.putExtra("received_message", received_message); startActivity(i); } sendNotification("MESSAGE RECEIVED :" + received_message); Intent sendIntent = new Intent("message_recieved"); sendIntent.putExtra("message", received_message); LocalBroadcastManager.getInstance(this).sendBroadcast(sendIntent); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); Log.d(TAG, extras.toString()); if (!extras.isEmpty()) { String message = extras.getString("message"); if (message != null) { sendNotification(message); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (extras != null && !extras.isEmpty()) { // has effect of unparcelling Bundle // Since we're not using two way messaging, this is all we really to check for if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { Logger.getLogger("GCM_RECEIVED").log(Level.INFO, extras.toString()); notifyMe(extras.getString("name"), extras.getString("description")); } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); mes = extras.getString("message"); showNotification(); Log.i("GCM", "Received : (" + messageType + ") " + extras.getString("title")); GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { sendNotification("Message Received from Google GCM Server:\n\n" + extras.get("message")); } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /* * Filter messages based on message type. Since it is likely that GCM * will be extended in the future with new message types, just ignore * any message types you're not interested in, or that you don't * recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString(), "", "", ""); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString(), "", "", ""); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // This loop represents the service doing some work. for (int i = 0; i < 5; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(5000); } catch (InterruptedException e) { } } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. String mensaje = extras.getString("message"); String enlace = extras.getString("link"); String titulo = extras.getString("title"); String imagen = extras.getString("image"); sendNotification(mensaje, enlace, titulo, imagen); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /* * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ Log.w(TAG, "MessageType: " + messageType + " Extras: " + extras.toString()); Movintracks.getInstance().receivedGoogleCloudMessage(extras); } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you receive in your // BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /* * Filter messages based on message type.Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you 're * not interested in, or that you don 't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString(), null); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString(), null); // If it's a regular GCM message, do some work } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // Post notification of received message String message = extras.toString(); if (Globals.ACTION_CLEAR_NOTIFICATION.equals(extras.getString("action"))) { clearNotification(); } else if (Globals.ACTION_NOTIFICATION.equals(extras.getString("action"))) { sendNotification("Received: " + message, extras); } else { stopProgressBarIfRequired(extras); } Log.v(Globals.TAG, "Received: " + message); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { context = getApplicationContext(); chatArrayAdapter = new ChatArrayAdapter(getApplicationContext(), R.layout.activity_chat_singlemessage); Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (extras != null) { if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { if ("USERLIST".equals(extras.get("SM"))) { // update the userlist view Intent userListIntent = new Intent("com.example.admin.yama.userlist"); String userList = extras.get("USERLIST").toString(); userListIntent.putExtra("USERLIST", userList); sendBroadcast(userListIntent); } else if ("CHAT".equals(extras.get("SM"))) { Log.v("I WIN", "got a chat here"); USER_NAME = extras.get("Sender").toString(); Intent chatIntent = new Intent("com.example.admin.yama.chatmessage"); chatIntent.putExtra("Sender", extras.get("Sender").toString()); chatIntent.putExtra("CHATMESSAGE", extras.get("CHATMESSAGE").toString()); messageNotifictaion(chatIntent); sendBroadcast(chatIntent); } else if ("SIGNUPACK".equals(extras.get("SM"))) { SIGNUP_ACK = "Sign up with server complete"; } else if (Config.GOOGLE_PROJECT_ID.equals(extras.get("from"))) { } } } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Log.i("GCM", "Received a message."); Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // AccountManager accountManager = AccountManager.get(this.getApplicationContext()); // Account[] accounts = // accountManager.getAccountsByType(AuthenticatorActivity.ARG_ACCOUNT_TYPE); // for ( Account account : accounts ) { // //ContentResolver.requestSync(account, GewichtProvider.AUTHORITY, new // Bundle()); // } } } GcmBroadcastReceiver.completeWakefulIntent(intent); }