Example usage for android.os Bundle toString

List of usage examples for android.os Bundle toString

Introduction

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

Prototype

@Override
    public synchronized String toString() 

Source Link

Usage

From source file:com.dinamalarnellai.views.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. jav a2s  .  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());

            // Post notification of received message.
            try {
                sendNotification(extras.get("message").toString());
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

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

From source file:com.jens.voicemsg.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    // sendNotification("A Notification");

    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 ava2s. 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)) {
            // Post notification of received message.
            // sendNotification("Received: " + extras.toString());
            Log.i(LOG_TAG, "Received: " + extras.toString());
            onMessage(extras);
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:vn.co.taxinet.mobile.gps.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  .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)) {
            String riderName = intent.getStringExtra("name");
            String riderImage = intent.getStringExtra("image");
            String longitude = intent.getStringExtra("longitude");
            String latitude = intent.getStringExtra("latitude");
            String id = intent.getStringExtra("id");
            String phone = intent.getStringExtra("phone");
            String status = intent.getStringExtra("status");

            Intent intent2 = new Intent(Constants.BroadcastAction.DISPLAY_REQUEST);
            intent2.putExtra(Constants.IMAGE, riderImage);
            intent2.putExtra(Constants.NAME, riderName);
            intent2.putExtra(Constants.LONGITUDE, longitude);
            intent2.putExtra(Constants.LATITUDE, latitude);
            intent2.putExtra(Constants.ID, id);
            intent2.putExtra(Constants.PHONE, phone);
            intent2.putExtra(Constants.STATUS, status);

            sendBroadcast(intent2);

            System.out.println(extras);
            // send notification
            sendNotification("Received: " + extras.toString());
            // show alert

            // Utils.displayRequest(context, driverImage, driverName,
            // longitude, latitude, price)
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:bucci.dev.freestyle.TimerActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putLong(TIME_LEFT_PARAM, timeLeft);
    outState.putString(START_PAUSE_STATE_PARAM, (String) playButton.getTag());

    if (isExtraButtonShown)
        outState.putBoolean(SHOW_EXTRA_ROUND_BUTTON_PARAM, true);

    if (DEBUG)//  ww w .  j  av a2  s .c  o  m
        Log.i(TAG, "onSaveInstanceState(): " + outState.toString());
    super.onSaveInstanceState(outState);
}

From source file:london.vyne.pos.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Log.d(TAG, "Handling Intent");
    Bundle extras = intent.getExtras();

    Log.d(TAG, extras.getString("wine_order"));

    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  ava  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(extras.getString("wine_order"));
            //Log.i(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.example.notification.gcm.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 . j  a  va2s .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());

            // Post notification of received message.
            msg = extras.toString();
            status = extras.getString("status");
            check = extras.getString("check");
            notifier = "From: " + extras.getString("notifier");
            dbAdapter = new DatabaseAdapter(this);
            dbAdapter.open();
            title = notifier;
            body = "The status is " + status + "   " + "   Detail: " + check;
            dbAdapter.addNotif(title, body); // add notification into database
            sendNotification("Received: " + "Something happened. Let's solve it quickly!");
            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    WakefulBroadcastReceiver.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
        /*//from  w ww.j a v  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)) {
            //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
        /*/* ww w  .java  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)) {
            // 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:org.starfishrespect.myconsumption.android.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 == null || extras.isEmpty() || messageType == null || messageType.isEmpty())) { // has effect of unparcelling Bundle
        /*/* w  ww .  ja  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.
         */
        switch (messageType) {
        case GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR:
            LOGI(TAG, "Send error: " + extras.toString());
            break;
        case GoogleCloudMessaging.MESSAGE_TYPE_DELETED:
            LOGI(TAG, "Deleted messages on server: " + extras.toString());
            break;
        case GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE: // If it's a regular GCM message
            try {
                // Post notification of received message.
                sendNotification(extras.get("sensor").toString(), extras.get("message").toString());
                LOGI(TAG, "Received: " + extras.toString());
            } catch (Exception e) {
                LOGE(TAG, "Error while sending notification: " + e.toString());
            }
            break;
        }
    }
    // 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
        /*// www . j  av 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)) {
            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);
}