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:org.totschnig.myexpenses.sync.SyncAdapter.java

@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
        SyncResult syncResult) {//from  w  w  w  .  j  a v a  2s.com
    categoryToId = new HashMap<>();
    payeeToId = new HashMap<>();
    methodToId = new HashMap<>();
    accountUuidToId = new HashMap<>();
    String uuidFromExtras = extras.getString(KEY_UUID);
    Timber.i("onPerformSync " + extras.toString());

    AccountManager accountManager = AccountManager.get(getContext());

    Exceptional<SyncBackendProvider> backendProviderExceptional = SyncBackendProviderFactory.get(getContext(),
            account);
    SyncBackendProvider backend;
    try {
        backend = backendProviderExceptional.getOrThrow();
    } catch (Throwable throwable) {
        syncResult.databaseError = true;
        AcraHelper.report(throwable instanceof Exception ? ((Exception) throwable) : new Exception(throwable));
        GenericAccountService.deactivateSync(account);
        accountManager.setUserData(account, GenericAccountService.KEY_BROKEN, "1");
        String content = String.format(Locale.ROOT,
                "The backend could not be instantiated.Reason: %s. Please try to delete and recreate it.",
                throwable.getMessage());
        Intent manageIntent = new Intent(getContext(), ManageSyncBackends.class);
        NotificationBuilderWrapper builder = NotificationBuilderWrapper
                .defaultBigTextStyleBuilder(getContext(), "Synchronization backend deactivated", content)
                .setContentIntent(PendingIntent.getActivity(getContext(), 0, manageIntent,
                        PendingIntent.FLAG_CANCEL_CURRENT));
        Notification notification = builder.build();
        notification.flags = Notification.FLAG_AUTO_CANCEL;
        ((NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE)).notify(0,
                notification);
        return;
    }
    if (!backend.setUp()) {
        syncResult.stats.numIoExceptions++;
        syncResult.delayUntil = 300;
        return;
    }

    String autoBackupFileUri = extras.getString(KEY_UPLOAD_AUTO_BACKUP);
    if (autoBackupFileUri != null) {
        try {
            backend.storeBackup(Uri.parse(autoBackupFileUri));
        } catch (IOException e) {
            String content = getContext().getString(R.string.auto_backup_cloud_failure, autoBackupFileUri,
                    account.name) + " " + e.getMessage();
            Notification notification = NotificationBuilderWrapper.defaultBigTextStyleBuilder(getContext(),
                    getContext().getString(R.string.pref_auto_backup_title), content).build();
            notification.flags = Notification.FLAG_AUTO_CANCEL;
            ((NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE)).notify(0,
                    notification);
        }
        return;
    }

    Cursor c;

    String[] selectionArgs;
    String selection = KEY_SYNC_ACCOUNT_NAME + " = ?";
    if (uuidFromExtras != null) {
        selection += " AND " + KEY_UUID + " = ?";
        selectionArgs = new String[] { account.name, uuidFromExtras };
    } else {
        selectionArgs = new String[] { account.name };
    }
    String[] projection = { KEY_ROWID };
    try {
        c = provider.query(TransactionProvider.ACCOUNTS_URI, projection,
                selection + " AND " + KEY_SYNC_SEQUENCE_LOCAL + " = 0", selectionArgs, null);
    } catch (RemoteException e) {
        syncResult.databaseError = true;
        AcraHelper.report(e);
        return;
    }
    if (c == null) {
        syncResult.databaseError = true;
        AcraHelper.report("Cursor is null");
        return;
    }
    if (c.moveToFirst()) {
        do {
            long accountId = c.getLong(0);
            try {
                provider.update(buildInitializationUri(accountId), new ContentValues(0), null, null);
            } catch (RemoteException e) {
                syncResult.databaseError = true;
                AcraHelper.report(e);
                return;
            }
        } while (c.moveToNext());
    }

    try {
        c = provider.query(TransactionProvider.ACCOUNTS_URI, projection, selection, selectionArgs, null);
    } catch (RemoteException e) {
        syncResult.databaseError = true;
        AcraHelper.report(e);
        return;
    }
    if (c != null) {
        if (c.moveToFirst()) {
            do {
                long accountId = c.getLong(0);

                String lastLocalSyncKey = KEY_LAST_SYNCED_LOCAL(accountId);
                String lastRemoteSyncKey = KEY_LAST_SYNCED_REMOTE(accountId);

                long lastSyncedLocal = Long
                        .parseLong(getUserDataWithDefault(accountManager, account, lastLocalSyncKey, "0"));
                long lastSyncedRemote = Long
                        .parseLong(getUserDataWithDefault(accountManager, account, lastRemoteSyncKey, "0"));
                dbAccount.set(org.totschnig.myexpenses.model.Account.getInstanceFromDb(accountId));
                Timber.i("now syncing " + dbAccount.get().label);
                if (uuidFromExtras != null && extras.getBoolean(KEY_RESET_REMOTE_ACCOUNT)) {
                    if (!backend.resetAccountData(uuidFromExtras)) {
                        syncResult.stats.numIoExceptions++;
                        Timber.e("error resetting account data");
                    }
                    continue;
                }
                if (!backend.withAccount(dbAccount.get())) {
                    syncResult.stats.numIoExceptions++;
                    Timber.e("error withAccount");
                    continue;
                }

                if (backend.lock()) {
                    try {
                        ChangeSet changeSetSince = backend.getChangeSetSince(lastSyncedRemote, getContext());

                        if (changeSetSince.isFailed()) {
                            syncResult.stats.numIoExceptions++;
                            Timber.e("error getting changeset");
                            continue;
                        }

                        List<TransactionChange> remoteChanges;
                        lastSyncedRemote = changeSetSince.sequenceNumber;
                        remoteChanges = changeSetSince.changes;

                        List<TransactionChange> localChanges = new ArrayList<>();
                        long sequenceToTest = lastSyncedLocal + 1;
                        while (true) {
                            List<TransactionChange> nextChanges = getLocalChanges(provider, accountId,
                                    sequenceToTest);
                            if (nextChanges.size() > 0) {
                                localChanges.addAll(
                                        Stream.of(nextChanges).filter(change -> !change.isEmpty()).toList());
                                lastSyncedLocal = sequenceToTest;
                                sequenceToTest++;
                            } else {
                                break;
                            }
                        }

                        if (localChanges.size() == 0 && remoteChanges.size() == 0) {
                            continue;
                        }

                        if (localChanges.size() > 0) {
                            localChanges = collectSplits(localChanges);
                        }

                        Pair<List<TransactionChange>, List<TransactionChange>> mergeResult = mergeChangeSets(
                                localChanges, remoteChanges);
                        localChanges = mergeResult.first;
                        remoteChanges = mergeResult.second;

                        if (remoteChanges.size() > 0) {
                            writeRemoteChangesToDb(provider,
                                    Stream.of(remoteChanges)
                                            .filter(change -> !(change.isCreate() && uuidExists(change.uuid())))
                                            .toList(),
                                    accountId);
                            accountManager.setUserData(account, lastRemoteSyncKey,
                                    String.valueOf(lastSyncedRemote));
                        }

                        if (localChanges.size() > 0) {
                            lastSyncedRemote = backend.writeChangeSet(localChanges, getContext());
                            if (lastSyncedRemote != ChangeSet.FAILED) {
                                if (!BuildConfig.DEBUG) {
                                    // on debug build for auditing purposes, we keep changes in the table
                                    provider.delete(TransactionProvider.CHANGES_URI,
                                            KEY_ACCOUNTID + " = ? AND " + KEY_SYNC_SEQUENCE_LOCAL + " <= ?",
                                            new String[] { String.valueOf(accountId),
                                                    String.valueOf(lastSyncedLocal) });
                                }
                                accountManager.setUserData(account, lastLocalSyncKey,
                                        String.valueOf(lastSyncedLocal));
                                accountManager.setUserData(account, lastRemoteSyncKey,
                                        String.valueOf(lastSyncedRemote));
                            }
                        }
                    } catch (IOException e) {
                        Timber.e(e, "Error while syncing ");
                        syncResult.stats.numIoExceptions++;
                    } catch (RemoteException | OperationApplicationException | SQLiteException e) {
                        Timber.e(e, "Error while syncing ");
                        syncResult.databaseError = true;
                        AcraHelper.report(e);
                    } finally {
                        if (!backend.unlock()) {
                            Timber.e("Unlocking backend failed");
                            syncResult.stats.numIoExceptions++;
                        }
                    }
                } else {
                    //TODO syncResult.delayUntil = ???
                    syncResult.stats.numIoExceptions++;
                }
            } while (c.moveToNext());
        }
        c.close();
    }
    backend.tearDown();
}

From source file:app.com.ark.android.sunshine.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
    String messageType = gcm.getMessageType(intent);

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*/*from  www . ja va 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_MESSAGE.equals(messageType)) {
            // Is this our message?? Better be if you're going to act on it!
            if (MainActivity.PROJECT_NUMBER.equals(extras.getString(EXTRA_SENDER))) {
                // Process message and then post a notification of the received message.
                String weather = extras.getString(EXTRA_WEATHER);
                String location = extras.getString(EXTRA_LOCATION);
                String alert = "Heads up: " + weather + " in " + location + "!";

                sendNotification(context, alert);
            }

            Log.i(LOG_TAG, "Received: " + extras.toString());
        }
    }
}

From source file:br.com.imovelhunter.imovelhunterwebmobile.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 (SessionUtilJson.getInstance(getApplicationContext())
            .containsName(ParametrosSessaoJson.USUARIO_LOGADO)) {
        usuarioLogado = (Usuario) SessionUtilJson.getInstance(getApplicationContext())
                .getJsonObject(ParametrosSessaoJson.USUARIO_LOGADO, Usuario.class);
    }//www . j a  v a2 s .com

    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 mensagem = extras.getString("mensagem");

            if (!mensagem.contains("idImovel")) {
                Mensagem mensagemO = new Mensagem();

                mensagemO.parse(mensagem);

                this.mensagem = mensagemO;

                this.mensagem.setLida(false);

                if (usuarioLogado != null && usuarioLogado.getIdUsuario() == this.mensagem.getUsuariosDestino()
                        .get(0).getIdUsuario()) {
                    sendNotification(mensagemO.getMensagem());
                }
            } else {
                Imovel imovel = new Imovel();
                imovel.parse(mensagem);
                String stringImovel = "Imovel encontrado em " + imovel.getEstado() + " - " + imovel.getBairro();
                sendNotificationImovel(stringImovel);
            }

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

From source file:com.chrismorais.android.sunshine.app.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
    String messageType = gcm.getMessageType(intent);

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*//w ww . j a va  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_MESSAGE.equals(messageType)) {
            // Is this our message?? Better be if you're going to act on it!
            if (MainActivity.PROJECT_NUMBER.equals(extras.getString(EXTRA_SENDER))) {
                // Process message and then post a notification of the received message.
                String weather = extras.getString(EXTRA_WEATHER);
                String location = extras.getString(EXTRA_LOCATION);
                String alert = "Heads up: " + weather + " in " + location + "!";

                sendNotification(context, alert);
            }

            Log.i(LOG_TAG, "Received: " + extras.toString());
        }
    }
}

From source file:com.grokkingandroid.sampleapp.samples.gcm.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    mSenderId = getResources().getString(R.string.gcm_project_id);
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);

    // action handling for actions of the activity
    String action = intent.getAction();
    Log.v("grokkingandroid", "action: " + action);
    if (action.equals(Constants.ACTION_REGISTER)) {
        register(gcm, intent);/*from  w  ww .  j av a  2  s .  co m*/
    } else if (action.equals(Constants.ACTION_UNREGISTER)) {
        unregister(gcm, intent);
    } else if (action.equals(Constants.ACTION_ECHO)) {
        sendMessage(gcm, intent);
    }

    // handling of stuff as described on
    // http://developer.android.com/google/gcm/client.html
    try {
        Bundle extras = intent.getExtras();
        // The getMessageType() intent parameter must be the intent you
        // received in your BroadcastReceiver.
        String messageType = gcm.getMessageType(intent);

        if (extras != null && !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)) {
                // Post notification of received message.
                String msg = extras.getString("message");
                if (TextUtils.isEmpty(msg)) {
                    msg = "empty message";
                }
                sendNotification(msg);
                Log.i("grokkingandroid", "Received: " + extras.toString() + ", sent: " + msg);
            }
        }
    } finally {
        // Release the wake lock provided by the WakefulBroadcastReceiver.
        GcmBroadcastReceiver.completeWakefulIntent(intent);
    }
}

From source file:com.coderming.weatherwatch.gcm.MyGcmListenerService.java

/**
 * Called when message is received./*  w  w  w.  ja va2s .co m*/
 *
 * @param from SenderID of the sender.
 * @param data Data bundle containing message data as key/value pairs.
 *             For Set of keys use data.keySet().
 */
@Override
public void onMessageReceived(String from, Bundle data) {
    // Time to unparcel the bundle!
    if (!data.isEmpty()) {
        // TODO: gcm_default sender ID comes from the API console
        String senderId = getString(R.string.gcm_defaultSenderId);
        if (senderId.length() == 0) {
            Toast.makeText(this, "SenderID string needs to be set", Toast.LENGTH_LONG).show();
        }
        // Not a bad idea to check that the message is coming from your server.
        if ((senderId).equals(from)) {
            // Process message and then post a notification of the received message.
            try {
                JSONObject jsonObject = new JSONObject(data.getString(EXTRA_DATA));
                String weather = jsonObject.getString(EXTRA_WEATHER);
                String location = jsonObject.getString(EXTRA_LOCATION);
                String alert = String.format(getString(R.string.gcm_weather_alert), weather, location);
                sendNotification(alert);
            } catch (JSONException e) {
                // JSON parsing failed, so we just let this message go, since GCM is not one
                // of our critical features.
            }
        }
        Log.i(TAG, "Received: " + data.toString());
    }
}

From source file:mobisocial.musubi.ui.fragments.AccountLinkDialog.java

public void postActivityToFeed() {
    SharedPreferences p = mActivity.getSharedPreferences(SettingsActivity.PREFS_NAME, 0);
    if (p.getBoolean(SettingsActivity.PREF_ALREADY_SAW_FACEBOOK_POST, false)) {
        return;/*from  w w  w.  ja v a2s .c o m*/
    }
    p.edit().putBoolean(SettingsActivity.PREF_ALREADY_SAW_FACEBOOK_POST, true).commit();
    Bundle post = new Bundle();
    post.putString("picture",
            "https://lh5.ggpht.com/hRTJJv7H9dpLXhHTTqiiNY2DD2wWO0hZFWEWPv1g-WArcUYLsWk-aQYUS0UgZfVIqtXm=w124");
    post.putString("link", "https://market.android.com/details?id=mobisocial.musubi");
    post.putString("caption", "Musubi");
    post.putString("description", "I'm using Musubi, a social network without the Cloud for smartphones.");
    Facebook facebook = getFacebookInstance(mActivity);
    facebook.dialog(mActivity, "feed", post, new Facebook.DialogListener() {

        @Override
        public void onComplete(Bundle values) {
            Log.i(TAG, values.toString());
        }

        @Override
        public void onFacebookError(FacebookError e) {
            Log.e(TAG, e.toString());
        }

        @Override
        public void onError(DialogError e) {
            Log.e(TAG, e.toString());
        }

        @Override
        public void onCancel() {
            Log.i(TAG, "User canceled post to Facebook.");
        }

    });
}

From source file:com.nzsoft.myweather.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
    String messageType = gcm.getMessageType(intent);

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*/*from   ww 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_MESSAGE.equals(messageType)) {
            // Is this our message?? Better be if you're going to act on it!
            Log.d(LOG_TAG, "extras.getString(EXTRA_SENDER)" + extras.getString(EXTRA_SENDER));
            if (MainActivity.PROJECT_NUMBER.equals(extras.getString(EXTRA_SENDER))) {
                Log.d(LOG_TAG, "onReceive if send notif");
                // Process message and then post a notification of the received message.
                String weather = extras.getString(EXTRA_WEATHER);
                String location = extras.getString(EXTRA_LOCATION);
                String alert = "Heads up: " + weather + " in " + location + "!";

                sendNotification(context, alert);
            }

            Log.i(LOG_TAG, "Received: " + extras.toString());
        }
    }
}

From source file:edu.mit.dormbell.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())
        /*/*  w w  w.  jav  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("CloudBackend", "onHandleIntent: message error");
        else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType))
            Log.i("CloudBackend", "onHandleIntent: message deleted");
        // If it's a regular GCM message, do some work.
        else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            // Post notification of received message.
            Log.i(TAG, "Received: " + extras.toString());

            if (context == null) {
                Log.i(TAG, "null conxtext");
                System.out.println(getFilesDir().getAbsolutePath());
                MainActivity.initAppData(getFilesDir().getAbsolutePath());
            }

            try {
                if (extras.getString("type").equals("ring")) {
                    /*JSONArray eve = MainActivity.appData.getJSONArray("events");  TODO: Eventually check the hash to see if the notification was already received
                    for(int i = 0; i < eve.length(); i++)
                    {
                       System.out.println(eveData.getString("hash"));
                       System.out.println(eve.getJSONObject(i).getString("hash"));
                       if(extras.getString("hash").equals(eve.getJSONObject(i).getString("hash")))
                    return;
                    }*/
                    /*eveData.accumulate("member",false);                       TODO: If not already received add to list
                    System.out.println(eveData.getLong("date"));
                    System.out.println(Calendar.getInstance().getTimeInMillis());
                    if(eveData.getLong("date") < Calendar.getInstance().getTimeInMillis())
                       return;
                    eve.put(eveData);*/

                    Bundle data = new Bundle();

                    String sender = extras.getString("sender");
                    String senderfull = extras.getString("senderfull");
                    String lock = extras.getString("lock");

                    Intent ringIntent = new Intent(this, MainActivity.class);
                    data.putString("sender", sender);
                    data.putString("senderfull", senderfull);
                    ringIntent.putExtra("flag", "ringring");
                    ringIntent.putExtra("data", data);

                    Notify(sender + " is outside", "get them at " + lock, 0, ringIntent);

                }

                MainActivity.saveAppData(getFilesDir().getAbsolutePath());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    MainBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.example.hjcyz1991.project407.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);
    String title = extras.getString("title");
    String inBody = new String(extras.getString("body"));
    if (body.contains(inBody)) {
        int idx = body.indexOf(inBody);
        if (idx != 0) {
            body.remove(inBody);//from  www . j a va 2s .  c  o  m
            body.add(0, inBody);
            if (body.size() > bodyLen)
                body.remove(bodyLen);
        }
    } else {
        body.add(0, inBody);
        if (body.size() > bodyLen)
            body.remove(bodyLen);
    }
    Log.d("GCM", body.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("GCM Notification", "Send error: " + extras.toString());
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            sendNotification("GCM Notification", "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(title, inBody);
            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}