Example usage for android.os Bundle isEmpty

List of usage examples for android.os Bundle isEmpty

Introduction

In this page you can find the example usage for android.os Bundle isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if the mapping of this Bundle is empty, false otherwise.

Usage

From source file:com.rampgreen.caretakermobile.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

        /*/*www .j  a va2  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("Error", "Send error: " + extras.toString());
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            sendNotification("Deleted Messages", "Deleted messages on server: " + extras.toString());
            // If it's a regular GCM message, do some work.
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            GcmMsgBean gcmMsgBean = null;
            String msg = null;
            try {
                msg = extras.getString("message");
                JSONObject jsonObject = new JSONObject(msg);
                gcmMsgBean = new GcmMsgBean();
                gcmMsgBean.parseGcmMsg(jsonObject);
            } catch (JSONException e) {
                AppLog.printStackTrace(e);
            }

            if (gcmMsgBean == null || msg == null) {
                return;
            }

            String title = gcmMsgBean.getNotificationTitle();
            String subtitle = gcmMsgBean.getNotificationSubTitle();
            msg = title + ":" + subtitle;
            String msgList = (String) AppSettings.getPrefernce(this, null, AppSettings.STORE_NOTI_LIST, "");
            if (StringUtils.isEmpty(msgList)) {
                msgList = msg;
            } else {
                msgList = msgList + "|" + msg;
            }
            AppSettings.setPreference(this, null, AppSettings.STORE_NOTI_LIST, msgList);
            sendNotification(gcmMsgBean.getNotificationTitle(), gcmMsgBean.getNotificationSubTitle());
            AppLog.d(TAG, "Received: " + extras.toString());

        }

        // 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.

        //         }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:org.openchaos.android.buildmessage.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  va  2s.  com*/
         * 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.w(TAG, "Send error: " + extras.toString());
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            Log.w(TAG, "Deleted messages on server: " + extras.toString());
            // If it's a regular GCM message, do some work.
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            Log.i(TAG, "Received message: " + extras.toString());
            String sender = extras.getString("from");
            int senderIndex = 0;
            // TODO: multiple senders in a string set
            if (!((sender != null) && sender.equals(prefs.getString("sender_id_1", null)))) {
                Log.w(TAG, "Unknown GCM sender: " + sender);
                //               return;
            }

            createNotification(senderIndex, extras.getString("m"), extras.getString("i"));
        } else {
            Log.d(TAG, "Unknown GCM message type. Message ignored: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:ch.mobileking.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);
    System.out.println("GcmIntentService called: " + extras.toString());

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*//from w  w  w. j  av  a 2s  .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)) {
            // 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.aylanetworks.aura.GcmIntentService.java

@SuppressWarnings("unchecked")
@Override/*from   w  w  w .ja v a 2s.c  o  m*/
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(), 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)) {
            // This loop represents the service doing some work.
            //PushNotification.playSound("Beep_once.ogg");
            for (int i = 0; i < 3; i++) {
                Log.i(TAG, "Working... " + (i + 1) + "/3 @ " + SystemClock.elapsedRealtime());
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                }
            }
            Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
            // Post notification of received message.
            String message = extras.getString("message");
            String sound = extras.getString("sound");
            //String other = extras.getString("other");
            sendNotification(message, sound);
            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.nobledesignlabs.lookupaddress.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
        /*/*w w w.j a v  a  2 s .com*/
         * 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)) {
            // displayNotification(this,"Send error: " + extras);
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            // displayNotification(this,"Deleted messages on server: "
            // + extras);
            // 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.
            // Post notification of received message.
            displayNotification(this, extras);
            Log.i(CommonStuff.TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.example.demoflavius.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    String message = intent.getExtras().getString("message");
    // 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 w  w .  ja  va 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)) {
            // Post notification of received message.
            sendNotification(message);
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.procialize.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    System.out.println("Inside OnHandle Intent");
    sendNotification("Received: ");
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    // The getMessageType() intent parameter must be the intent you received
    // in your BroadcastReceiver.
    // GCM Message TYpe
    // String messageType = gcm.getMessageType(intent);
    String messageType = "gcm";

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*//from   ww w . j av  a 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)) {
            // 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.smashedin.smashedin.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
        /*//  w  ww  .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.
         */
        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 groupType = extras.getString("instanttype", "text");
            String uniqueid = extras.getString("uniqueid", "theju");
            if (groupType.equals("delete")) {
                MyGroupDataSingleton.getInstance().RemoveGroup(uniqueid);
            } else if (groupType.equals("request")) {
                String bname = extras.getString("bname", "");
                String username = extras.getString("username", "");
                uniqueid = extras.getString("uniqueid", "");
                Intent groupintent = new Intent("group-accept-event");
                groupintent.putExtra("uniqueid", uniqueid);
                groupintent.putExtra("bname", bname);
                groupintent.putExtra("username", username);
                LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(groupintent);

            } else if (uniqueid.contains("theju") != true) {
                Singleton.getInstance().m_strMessageGcm = extras.getString("live", "");
                Singleton.getInstance().m_strMessageGcmUser = extras.getString("username", "");
                Singleton.getInstance().m_strMessageGcmBid = extras.getString("bid", "");
                Singleton.getInstance().m_strMessageGcmBname = extras.getString("bname", "");
                Singleton.getInstance().m_strMessageGcmLocation = extras.getString("atplace", "");
                Singleton.getInstance().m_iMessageGcmTimestamp = Long.valueOf(extras.getString("timestamp"))
                        .longValue();
                Singleton.getInstance().m_strMessageType = extras.getString("instanttype", "text");
                Singleton.getInstance().m_strOhUrl = extras.getString("ohurl", "");
                Singleton.getInstance().uniqueid = uniqueid;
                // This loop represents the service doing some work.
                // Post notification of received message.
                //sendNotification("Received: " + extras.toString());
                Intent pushintent = new Intent("push-group-event");
                LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(pushintent);

            } else {
                Singleton.getInstance().m_strMessageGcm = extras.getString("live", "");
                Singleton.getInstance().m_strMessageGcmUser = extras.getString("username", "");
                Singleton.getInstance().m_strMessageGcmBid = extras.getString("bid", "");
                Singleton.getInstance().m_strMessageGcmBname = extras.getString("bname", "");
                Singleton.getInstance().m_strMessageGcmLocation = extras.getString("atplace", "");
                Singleton.getInstance().m_iMessageGcmTimestamp = Long.valueOf(extras.getString("timestamp"))
                        .longValue();
                Singleton.getInstance().m_strMessageType = extras.getString("instanttype", "text");
                Singleton.getInstance().m_strOhUrl = extras.getString("ohurl", "");
                // This loop represents the service doing some work.
                // Post notification of received message.
                //sendNotification("Received: " + extras.toString());
                Intent pushintent = new Intent("push-event");
                LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(pushintent);
            }

        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:net.stefanopallicca.android.awsmonitor.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);
    Log.i(TAG + ":onMessage extras ", extras.getString("body"));
    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*//from w w  w  .jav 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.
         */
        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 messageBody = extras.getString("body");
            //sendNotification("Received: " + extras.toString());
            NotificationsDatasource nd = new NotificationsDatasource(getApplicationContext());
            nd.open();
            //String messageBody = (String) intent.getExtras().getCharSequence("body"); 
            nd.dbAddNotification(messageBody);
            // Invia messaggio
            sendNotification(messageBody);
            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.androidbegin.gcmtutorial.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {

    Log.e(TAG, "Service handle message");
    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);

    Log.e("tag", extras.toString() + "      " + messageType.toString());

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*/*from   w  w  w.  j  av  a  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)) {
            // This loop represents the service doing some work.
            for (int i = 0; i < 5; i++) {
                Log.e(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime());
                // try {
                // Thread.sleep(5000);
                // } catch (InterruptedException e) {
                // }
            }
            Log.e(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
            // Post notification of received message.
            sendNotification("Received: " + extras.toString());
            Log.e(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}