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.nicolacimmino.expensestracker.tracker.data_sync.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()) {

        // We ignore other message types (error, deleted etc.) we just process messages.
        if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {

            // We know something changed on the server, so we request a sync of the ExpensesDataPRovider
            getContentResolver().requestSync(ExpensesAccountResolver.getInstance().getAccount(),
                    ExpensesDataContentProvider.Contract.CONTENT_AUTHORITY, extras);

            // Post notification of received message.
            showExpensesUpdatedNotification();

            Log.i(TAG, "Received: " + extras.toString());
        }//from  w  ww. j  a  v  a 2 s. co  m
    }

    // Release the wake lock provided by the WakefulBroadcastReceiver. This signals that we are
    // done and the device doesn't need to be kept awake anymore.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:uk.org.downiesoft.slideshow.GridViewFragment.java

/**
 * {@inheritDoc}/*from   www.  j  a  v  a2  s. c  o  m*/
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SlideShowActivity.debug(1, TAG, "onCreate: %d %s", mCurrentImage,
            savedInstanceState == null ? "null" : savedInstanceState.toString());
    mSettings = PreferenceManager.getDefaultSharedPreferences(getActivity());
    mThumbSize = getThumbSizeSetting();
    mCurrentScrollY = 0;
}

From source file:uk.org.downiesoft.slideshow.GridViewFragment.java

/**
 * {@inheritDoc}//from   ww  w  . j  av  a 2  s.com
 */
@Override
public void onViewStateRestored(Bundle outState) {
    super.onViewStateRestored(outState);
    SlideShowActivity.debug(1, TAG, "onViewStateRestored: %d %s", mCurrentImage,
            outState == null ? "null" : outState.toString());
    if (outState != null) {
        mCurrentImage = outState.getInt("currentImage", 0);
    } else {
        mCurrentImage = mSettings.getInt(SettingsActivity.PREFS_CURRENTIMAGE, 0);
        mCurrentScrollY = mSettings.getInt(SettingsActivity.PREFS_FIRSTIMAGE, 0);
    }
    if (mThumbnailAdapter == null) {
        mThumbnailAdapter = new ThumbnailAdapter(getActivity(), mCurrentFile, mCurrentImage, mThumbSize, this);
    }
    if (mPreview != null) {
        mPreview.setPresentation(mThumbnailAdapter.getPresentation(), mCurrentImage);
    }
    mGridView.setAdapter(mThumbnailAdapter);
}

From source file:net.vidainc.vidahome.service.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();
    switch (action) {
    case Constants.ACTION_REGISTER:
        register(gcm);//from   w  w w  .  j ava 2  s . c  o m
        break;
    case Constants.ACTION_UNREGISTER:
        unregister(gcm, intent);
        break;
    case Constants.ACTION_BEACON_DATA:
        sendBeaconData(gcm, intent);
        break;
    }

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

From source file:com.carpool.dj.carpool.model.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 av  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)) {
            // This loop represents the service doing some work.
            /*
            for (int i=0; i<5; i++) {
            Log.i("", "Working... " + (i+1)
                    + "/5 @ " + SystemClock.elapsedRealtime());
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
            }
            }*/
            //Log.i("", "Completed work @ " + SystemClock.elapsedRealtime());
            // Post notification of received message.
            //sendNotification("Received: " + extras.toString());
            onMessage(Utils.nowActivity, intent);
            Log.i("", "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:edu.mines.letschat.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 .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(), "0");
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            sendNotification("Deleted messages on server: " + extras.toString(), "0");
            // 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 message = (String) extras.get("message");
            messages.add(message);

            String picture = (String) extras.get("picture");

            String senderID = (String) extras.get("sender");
            String recipientID = (String) extras.get("recipient");
            sendNotification(message, senderID);
            Log.v(TAG, "Received: " + message);

            Log.i(TAG, "Received: " + extras.toString());
            Intent resultBroadCastIntent = new Intent();
            /*set action here*/
            resultBroadCastIntent.setAction(
                    edu.mines.letschat.MessageActivity.TextCapitalizeResultReceiver.ACTION_TEXT_CAPITALIZED);
            /*set intent category as default*/
            resultBroadCastIntent.addCategory(Intent.CATEGORY_DEFAULT);

            /*add data to intent*/
            resultBroadCastIntent.putExtra(OUTPUT_TEXT, message);
            //              Log.v(TAG, "Sender id " + senderID + " recieve id " + recipientID);
            Log.v(TAG, picture);
            Conversation convo = new Conversation(getApplicationContext(), senderID, recipientID, message,
                    false, picture);
            convo.save();

            if (!picture.isEmpty()) {
                new DownloadImage(picture).execute();
            }

            /*send broadcast */
            sendBroadcast(resultBroadCastIntent);
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReviever.completeWakefulIntent(intent);
}

From source file:com.tws.soul.soulbrown.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 .jav 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)) {
            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) {
            }
            }
            */

            String msg = extras.getString("msg");
            String pushFlag = extras.getString("pushflag");
            int status = extras.getInt("status");

            LOG.d("GcmIntentService msg : " + msg + " pushFlag : " + pushFlag + " status : " + status);

            String decMsg = "";
            try {
                decMsg = URLDecoder.decode(msg, "utf-8");

            } catch (Exception e) {
                decMsg = "";
            }

            Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
            // Post notification of received message.

            if (!TextUtils.isEmpty(decMsg)) {

                sendNotification(decMsg);

                Intent intentGcm = new Intent(GCM_BROADCAST);

                intentGcm.putExtra("msg", decMsg);

                LocalBroadcastManager.getInstance(this).sendBroadcast(intentGcm);

                // alarm , geofence off
                if (pushFlag.equals(GcmDefine.PUSH_CHG_ORDER)) {

                    //if( status == 1 ) {
                    LOG.d("GcmIntentService alarm , geofence off");

                    PrefOrderInfo prefOrderInfo = new PrefOrderInfo(this);
                    prefOrderInfo.setArriveTime(0);
                    prefOrderInfo.setOrderStore("");

                    AlarmManagerBroadcastReceiver alarmManagerBroadcastReceiver = new AlarmManagerBroadcastReceiver();
                    alarmManagerBroadcastReceiver.cancelAlarm(this);

                    geofenceClient = new GeofenceClient(this, GeofenceResultHandler);
                    //}
                } else if (pushFlag.equals(GcmDefine.PUSH_CANCEL_ORDER)
                        || pushFlag.equals(GcmDefine.PUSH_APPROACH_USER)
                        || pushFlag.equals(GcmDefine.PUSH_NEW_ORDER)) {
                    // alarm service call

                    Intent intentSvc = new Intent(this, AlarmNotiService.class);

                    this.startService(intentSvc);

                } else if (pushFlag.equals(GcmDefine.PUSH_CHG_PUSHKEY)) {
                    setPushStatus(0);
                }

            }
            Log.i(TAG, "Received: " + decMsg);

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

From source file:com.app.easyblood.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
        /*//  ww w. ja v  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)) {

            type = extras.getString("Type");
            intType = Integer.parseInt(type);
            switch (intType) {
            case 1:
                verifyUserId = extras.getString("UserId");
                break;
            case 2:

                askedby = extras.getString("AskedBy");
                category = extras.getString("Category");
                repliedby = extras.getString("RepliedBy");
                replymessage = extras.getString("ReplyMessage");
                userid_questions = extras.getString("UserId");
                questionmessage = extras.getString("QuestionMessage");
                asked_time_questions = extras.getString("AskedTime");
                imagepath = extras.getString("UserProfilePhotoServerPath");
                questionid = extras.getString("QuestionId");
                userprofession_questions = extras.getString("UserProfession");
                break;
            case 3: //New Request Notification
                message = extras.getString("message");
                requestId = extras.getString("requestId");
                username = extras.getString("userName");
                break;
            case 4://New Response Notification
                message = extras.getString("ResponseMessage");
                username = extras.getString("ResponseUserName");
                requestId = extras.getString("RequestId");
                userId = extras.getString("ResponseUserId");
                responseId = extras.getString("ResponseId");
                responseUserProfession = extras.getString("Profession");
                responseUserProfilePath = extras.getString("ProfilePhotoUrl");
                break;
            case 5:
                chatChatId = extras.getString("ChatId");
                chatMessage = extras.getString("Message");
                chatMessageTime = extras.getString("SentOn");
                chatSenderId = extras.getString("SenderId");
                chatSenderName = extras.getString("UserName");
                break;
            }

            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.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient.java

private boolean displayNotification(final Bundle pushBundle, final Class<?> targetClass, String imageUrl,
        String iconImageUrl, String iconSmallImageUrl, Map<String, String> campaignAttributes,
        String intentAction) {//from  w w  w  .  j a  va2 s.  c o  m
    log.info("Display Notification: " + pushBundle.toString());

    final String title = pushBundle.getString(NOTIFICATION_TITLE_PUSH_KEY);
    final String message = pushBundle.getString(NOTIFICATION_BODY_PUSH_KEY);

    final String campaignId = campaignAttributes.get(CAMPAIGN_ID_ATTRIBUTE_KEY);
    final String activityId = campaignAttributes.get(CAMPAIGN_ACTIVITY_ID_ATTRIBUTE_KEY);

    final int requestID = (campaignId + ":" + activityId + ":" + System.currentTimeMillis()).hashCode();

    final int iconResId = getNotificationIconResourceId(pushBundle.getString(NOTIFICATION_ICON_PUSH_KEY));
    if (iconResId == 0) {
        return false;
    }

    final Notification notification = createNotification(iconResId, title, message, imageUrl, iconImageUrl,
            iconSmallImageUrl,
            this.createOpenAppPendingIntent(pushBundle, targetClass, campaignId, requestID, intentAction));

    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.defaults |= Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE;

    if (android.os.Build.VERSION.SDK_INT >= ANDROID_LOLLIPOP) {
        log.info("SDK greater than 21 detected: " + android.os.Build.VERSION.SDK_INT);

        final String colorString = pushBundle.getString(NOTIFICATION_COLOR_PUSH_KEY);
        if (colorString != null) {
            int color;
            try {
                color = Color.parseColor(colorString);
            } catch (final IllegalArgumentException ex) {
                log.warn("Couldn't parse campaign notification color.", ex);
                color = 0;
            }
            Exception exception = null;
            try {
                final Field colorField = notification.getClass().getDeclaredField("color");
                colorField.setAccessible(true);
                colorField.set(notification, color);
            } catch (final IllegalAccessException ex) {
                exception = ex;
            } catch (final NoSuchFieldException ex) {
                exception = ex;
            }
            if (exception != null) {
                log.error("Couldn't set campaign notification color : " + exception.getMessage(), exception);
            }
        }
    }

    final NotificationManager notificationManager = (NotificationManager) pinpointContext
            .getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(requestID, notification);
    return true;
}

From source file:uk.org.downiesoft.slideshow.GridViewFragment.java

/**
 * {@inheritDoc}//from  w w w.  j  av a 2s. c  om
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    SlideShowActivity.debug(1, TAG, "onCreateView: %d %s", mCurrentImage,
            savedInstanceState == null ? "null" : savedInstanceState.toString());
    View parent = inflater.inflate(R.layout.gridview_fragment, container, false);
    mGridView = (GridView) parent.findViewById(R.id.gridview);
    mGridView.setEmptyView(parent.findViewById(R.id.emtpygridview));
    mProgressBar = (ProgressBar) parent.findViewById(R.id.gridviewProgressBar);
    mThumbSize = getThumbSizeSetting();
    mGridView.setColumnWidth(mThumbSize);
    mPreview = (PreviewFragment) getFragmentManager().findFragmentByTag(PreviewFragment.TAG);
    setHasOptionsMenu(true);
    // define actions to be taken when a thumbnail is clicked
    mGridView.setOnItemClickListener(new GridView.OnItemClickListener() {
        /**
         * {@inheritDoc}
         */
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (mPreview == null || mGridView.getChoiceMode() == ListView.CHOICE_MODE_NONE) {
                // Preview not visible so switch to slidshow view
                mCurrentImage = position;
                mGridView.setItemChecked(position, true);
                ActivityOptions options = ActivityOptions.makeScaleUpAnimation(mGridView, (int) view.getX(),
                        (int) view.getY(), view.getWidth(), view.getHeight());
                startSlideshow(mCurrentFile, position, false, options);
            } else {
                // Preview visible so action depends on which icon was clicked
                if (mCurrentImage == position) {
                    // currently selected icon so switch to slideshow view
                    ActivityOptions options = ActivityOptions.makeScaleUpAnimation(mGridView, (int) view.getX(),
                            (int) view.getY(), view.getWidth(), view.getHeight());
                    startSlideshow(mCurrentFile, position, false, options);
                } else {
                    // different icon so select it
                    mCurrentImage = position;
                    mCurrentScrollY = mGridView.getFirstVisiblePosition();
                    mGridView.setItemChecked(position, true);
                    mPreview.setImage(mCurrentImage);
                }
            }
        }

    });
    mGridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        /**
         * {@inheritDoc}
         */
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            // begin action mode
            mGridView.setMultiChoiceModeListener(new GridViewMultiChoiceModeListener());
            mGridView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
            mGridView.setItemChecked(position, true);
            return true;
        }
    });
    if (savedInstanceState != null) {
        SlideShowActivity.debug(1, TAG, "savedInstance: %s", savedInstanceState.toString());
        mShowingFavourites = savedInstanceState.getBoolean("showingFavourites");
        mCurrentFile = new ZFile(savedInstanceState.getString("currentFile", ""));
        if (mCurrentFile.toString().endsWith(getString(R.string.text_images_placeholder))) {
            mCurrentFile = new ZFile(mCurrentFile.getParentPath());
        }
        mCurrentImage = savedInstanceState.getInt("currentImage", 0);
        mPreviousFile = new ZFile(savedInstanceState.getString("previousFile"));
        if (mThumbnailAdapter == null) {
            mThumbnailAdapter = new ThumbnailAdapter(getActivity(), mCurrentFile, mCurrentImage, mThumbSize,
                    this);
        }
    } else {
        String defaultPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
                .toString();
        mCurrentFile = new ZFile(mSettings.getString(SettingsActivity.PREFS_LASTDIR, defaultPath));
        if (mCurrentFile.toString().endsWith(getString(R.string.text_images_placeholder))) {
            mCurrentFile = new ZFile(mCurrentFile.getParentPath());
        }
        if (!mCurrentFile.exists()) {
            mCurrentFile = new ZFile(defaultPath);
            mCurrentImage = mSettings.getInt(SettingsActivity.PREFS_CURRENTIMAGE, 0);
        }
        mPreviousFile = mCurrentFile;
        mThumbnailAdapter = new ThumbnailAdapter(getActivity(), mCurrentFile, mCurrentImage, mThumbSize, this);
    }
    mFavourites = FavouritesManager.getInstance(getActivity());
    if (savedInstanceState != null) {
        SlideShowActivity.debug(1, TAG, "onCreateView: %s", savedInstanceState.toString());
        mCurrentImage = savedInstanceState.getInt("currentImage", 0);
    }
    SlideShowActivity.debug(1, TAG, "onCreateView end: %d", mCurrentImage);
    return parent;
}