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.parabal.parabaltaskmanager.GcmIntentService.java

@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());
        }//from  w  ww  .  ja  va 2 s .c  o m

        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 prevents GCM from shutting down due to too fast sends ... this was part of their example so I don't know is 20s is the
            //accepted time or what
            //                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(extras.getString("message"));
            Log.i(TAG, "Received: " + extras.getString("message"));
        }
    }

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

From source file:de.teamklinge.mymusicteacher.gcm.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    String messageType = gcm.getMessageType(intent);

    if (!extras.isEmpty()) {
        // Nachrichten Filtern
        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());

            // Regulre Nachricht
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {

            // Android-Notification
            sendNotification("Schler X hat Interesse an Ihr Unterrichtsangebot!");
            Log.i(TAG, "Received: " + extras.toString());
        }/*from   www  .ja  v a2 s  . c  om*/
    }
    // 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
        /*//  w  ww .j  a 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)) {
            // 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:br.com.alquest.alquestdemo.app.Services.GcmIntentService.java

@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());
            Log.e(TAG, extras.toString());
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            Log.e(TAG, extras.toString());
            //sendNotification("Deleted messages on server: " + extras.toString());
        } 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);//  w w  w .j a  va  2  s.c  om
                  } catch (InterruptedException e) {
                  } */
            }
            //Log.e(TAG,intent.getStringExtra().toString());
            Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
            sendNotification("Received: " + intent.getStringExtra("type"), intent.getStringExtra("message"));
            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.cloudbees.gasp.gcm.GCMIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    String messageType = gcm.getMessageType(intent);

    try {/* ww  w  .j  a  va  2 s. c o  m*/
        if (!extras.isEmpty()) {
            if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
                Log.i(TAG, "Send error: " + extras.toString());
            } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
                Log.i(TAG, "Deleted messages on server: " + extras.toString());
            } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
                Log.i(TAG, "Received: " + extras.toString());

                int index = Integer.valueOf(extras.getString("id"));
                String table = extras.getString("table");
                String notificationMessage = "There's something new from Gasp!";

                if (table != null) {
                    if (table.matches("reviews")) {
                        startService(new Intent(getApplicationContext(), ReviewUpdateService.class)
                                .putExtra(ConsoleActivity.ResponseReceiver.PARAM_ID, index));
                    } else if (table.matches("restaurants")) {
                        startService(new Intent(getApplicationContext(), RestaurantUpdateService.class)
                                .putExtra(ConsoleActivity.ResponseReceiver.PARAM_ID, index));
                    } else if (table.matches("users")) {
                        startService(new Intent(getApplicationContext(), UserUpdateService.class)
                                .putExtra(ConsoleActivity.ResponseReceiver.PARAM_ID, index));
                    }
                    // Send notification message for message bar display etc
                    sendNotification(notificationMessage);
                } else {
                    Log.e(TAG, "Error: table not specified");
                }
                // Release the wake lock provided by the WakefulBroadcastReceiver.
                GCMBroadcastReceiver.completeWakefulIntent(intent);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.gcm.test.GCMIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    // TODO Auto-generated method stub

    Log.i("GCMIntentService", "sending push notification is" + intent.getStringExtra("message"));
    Bundle extras = intent.getExtras();
    String msg = intent.getStringExtra("message");
    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());
            // 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(500);
                } catch (InterruptedException e) {
                }/*from ww  w .j a va 2 s .c  o m*/
            }
            Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
            // Post notification of received message.
            //sendNotification("Received: " + extras.toString());
            sendNotification(msg);
            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    GCMBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.tonnguyen.livelotte.HomeActivity.java

@Override
protected void onSaveInstanceState(Bundle state) {
    Log.d(TAG, "onSaveInstanceState " + state.toString());
    // stop UI result update thread
    stopResultUpdaterThread();// w w w  .j  a  v  a 2  s .c  om
    // save the current session, so next time when user come back, we will load it
    Log.d(TAG, "storing currentDayIndex: " + currentDayIndex);
    state.putInt(SESSION_KEY, currentDayIndex);
    super.onSaveInstanceState(state);
}

From source file:com.appdynamics.demo.gasp.gcm.GCMIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    //AppDynamics
    CallTracker tracker = Instrumentation.beginCall("GCMIntentService", "onHandleIntent()", intent);

    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    String messageType = gcm.getMessageType(intent);

    try {/* w  w  w.  ja v a  2 s  . c o  m*/
        if (!extras.isEmpty()) {
            if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
                Log.i(TAG, "Send error: " + extras.toString());
            } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
                Log.i(TAG, "Deleted messages on server: " + extras.toString());
            } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
                Log.i(TAG, "Received: " + extras.toString());

                int index = Integer.valueOf(extras.getString("id"));
                String table = extras.getString("table");
                String notificationMessage = "There's something new from Gasp!";

                if (table != null) {
                    if (table.matches("reviews")) {
                        startService(new Intent(getApplicationContext(), ReviewUpdateService.class)
                                .putExtra(PARAM_ID, index));
                    } else if (table.matches("restaurants")) {
                        startService(new Intent(getApplicationContext(), RestaurantUpdateService.class)
                                .putExtra(PARAM_ID, index));
                    } else if (table.matches("users")) {
                        startService(new Intent(getApplicationContext(), UserUpdateService.class)
                                .putExtra(PARAM_ID, index));
                    }
                    // Send notification message for message bar display etc
                    sendNotification(notificationMessage);
                } else {
                    Log.e(TAG, "Error: table not specified");
                }
                // Release the wake lock provided by the WakefulBroadcastReceiver.
                GCMBroadcastReceiver.completeWakefulIntent(intent);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    //AppDynamics
    com.appdynamics.eumagent.runtime.Instrumentation.endCall(tracker);
}

From source file:com.tonnguyen.livelotte.HomeActivity.java

@Override
protected void onRestoreInstanceState(Bundle state) {
    Log.d(TAG, "onRestoreInstanceState " + state.toString());
    // restore the last session of user
    currentDayIndex = state.getInt(SESSION_KEY, 0);
    Log.d(TAG, "got currentDayIndex: " + currentDayIndex);

    //       today = DateTimeUtil.getCalendar();
    //      today.add(Calendar.DATE, currentDayIndex);  
    //      //bindData(ResultUtil.getResult(context, today), today);
    //      executeGetResultTask(today);
    viewPager.setCurrentItem(currentDayIndex);

    super.onRestoreInstanceState(state);
}

From source file:com.kasoft.pushnot.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    String title = "";
    String post = "";
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    String messageType = gcm.getMessageType(intent);
    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        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)) {
            Log.i(TAG, "Received: " + extras.toString());
            title = extras.getString("title");
            post = extras.getString("post");
            sendNotification(title + " " + post, title, post);
        }//from   www .j a va  2 s .  c o  m
    }
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}