List of usage examples for android.os Bundle isEmpty
public boolean isEmpty()
From source file:luan.com.flippit.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { mContext = this; mPrefs = getSharedPreferences(mContext.getPackageName(), Context.MODE_PRIVATE); mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); mBuilder = new NotificationCompat.Builder(this); activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String message = intent.getStringExtra("message"); 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()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { manageNotification(message); }/*from w ww . j a va 2s .c o m*/ } GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:fr.RivaMedia.alertes.GcmIntentService.java
@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 /*/*from w w w. j a v a 2 s. co m*/ * 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()); */ String message = extras.getString("message"); String annonces = extras.getString("annonces"); AlertesManager alertManager = new AlertesManager(getApplicationContext()); try { JSONArray arrayAnnonces = new JSONArray(annonces); for (int i = 0; i < arrayAnnonces.length(); ++i) { JSONObject objectAnnonce = arrayAnnonces.getJSONObject(i); String type = objectAnnonce.getString("type"); String id = objectAnnonce.getString("id"); alertManager.ajouter(id, type); } } catch (Exception e) { } Log.i(TAG, "Received: " + extras.toString()); Log.e(TAG, "ReceivedMessage: " + message.toString()); Log.e(TAG, "ReceivedAnnonces: " + annonces.toString()); // Post notification of received message. sendNotification(message, "Cliquez ici pour les consulter"); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.app.poke.poke.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { // mGoogleApiClient = ((MainActivityPhone)this.getApplicationContext()).mGoogleApiClient; 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 /*/* w ww . j a va2s . c o m*/ * 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)) { //SOCKET CODE /* try{ socket = IO.socket("http://192.168.1.69"); }catch(Exception e){ Log.e(TAG, "COnnect error"); } socket.connect(); // Receiving an object socket.on("Poke.poke", new Emitter.Listener() { @Override public void call(Object... args) { JSONObject obj = (JSONObject) args[0]; Log.i(TAG, "Received JSON"); try { if(obj.getString("to").equals(PokeConfig.CLIENT_ID)){ //Take server message and forward to watch (first node FIXME: more nodes? Collection<String> nodes = MainActivityPhone.getNodes(); String nodeid = nodes.iterator().next(); Log.d(TAG, "Node id: "+nodeid); MainActivityPhone.sendPokedMessage(nodeid); } } catch (JSONException e) { e.printStackTrace(); } } });*/ sendNotification("Poke from: " + extras.getString("to")); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.hackathon.BeatTheQueue.reusable.gcm.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); BTQSharedPreferences = new BTQSharedPreferences(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 /*//from w w w . j a v a2 s . c o m * 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)) { // Post notification of received message. String msg = extras.toString().split("\\[")[1]; msg = intent.getStringExtra("payLoad"); sendNotification(msg); Log.i(TAG, "Received: " + msg); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.boltarstudios.lok.GCMIntentService.java
@Override protected void onHandleIntent(Intent intent) { Log.i(Consts.TAG, "onHandleIntent"); 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 /*//from ww w . ja v a 2s. c om * 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)) { Log.i(Consts.TAG, "onHandleIntent: message error"); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.i(Consts.TAG, "onHandleIntent: message deleted"); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { String subId = intent.getStringExtra(GCM_KEY_SUBID); Log.i(Consts.TAG, "onHandleIntent: subId: " + subId); String[] tokens = subId.split(":"); String typeId = tokens[1]; // dispatch message if (GCM_TYPEID_QUERY.equals(typeId)) { Intent messageIntent = new Intent(BROADCAST_ON_MESSAGE); messageIntent.putExtras(intent); messageIntent.putExtra("token", tokens[2]); Log.i(Consts.TAG, "onHandleIntent: tokens: " + tokens[0] + ", " + tokens[1] + ", " + tokens[2] + ":end:"); LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent); } } } // Release the wake lock provided by the WakefulBroadcastReceiver. Log.i("wakeful", "completeWakefulIntent"); GCMBroadcastReceiver.completeWakefulIntent(intent); }
From source file:mdn.vtvsport.GcmIntentService.java
@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 /*//from w w w . j a v a 2s . c om * 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. */ // Toast.makeText(getApplicationContext(), "Received message gcm", Toast.LENGTH_LONG).show(); // String message = getString(R.string.gcm_message); String message = intent.getExtras().getString("message"); GCMInfo info = ParserManager.parserGCMResponse(message); if (TextUtils.isEmpty(info.getMessage())) { return; } // notifies user generateNotification(getApplicationContext(), info); // 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. // sendNotification("Received: " + extras.toString()); // Log.i(TAG, "Received: " + extras.toString()); // } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.campusconnect.gcm.GcmIntentService.java
@Override protected final void onHandleIntent(final 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 unpacking Bundle /*/*from ww w. j a v a 2 s . c om*/ * 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. */ switch (messageType) { case GoogleCloudMessaging.MESSAGE_TYPE_DELETED: sendNotification("Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. break; case GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE: if (intent.getStringExtra("NotificationKind").equals("PriceCheckLowerPrices1")) { final String message = getUserMessageForPriceCheckLowerPricesNotif(intent); Handler h = new Handler(Looper.getMainLooper()); h.post(new Runnable() { @Override public void run() { Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } }); } break; case GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR: default: sendNotification("Send error: " + extras.toString()); break; } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.sourceauditor.sahomemonitor.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { try {//from w w w . j a va 2 s . c o m 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(), extras); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString(), extras); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // Post notification of received message. if (USE_NOTIFICATION) { String msg = extras.getString(MainActivity.EXTRA_MESSAGE_FROM_HOME); if (msg == null || msg.trim().isEmpty()) { msg = "Home Alert (no message)"; } sendNotification(msg, extras); } else { sendToMainActivity(extras); } Log.i(TAG, "Received: " + extras.toString()); } } } finally { // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); } }
From source file:de.tum.in.tumcampus.services.GcmIntentService.java
@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 un-parcelling Bundle /*//from w w w . j a v a 2s . co m * 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_MESSAGE.equals(messageType)) { // Post notification of received message. sendNotification(extras); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.NotifyMe.GcmIntentService.java
@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 /*//from ww w. java 2 s . c o m * 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 service = extras.getString("service"); if (service.equals("NotifyMe")) { sendNotification(extras.getString("message")); } else { sendNotificationWithExtras(extras); } Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }