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.gmobi.poponews.gcm.MyGcmListenerService.java

/**
 * Called when message is received./*from  w w w . j a v a2s . c  o 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().
 */
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {
    String message = data.getString("message");
    String id = data.getString("itemId");
    Log.d(TAG, "From: " + from);
    Log.d(TAG, "Message: " + message);
    Log.d(TAG, "Itemid: " + data.toString());

    if (from.startsWith("/topics/")) {
        // message received from some topic.
    } else {
        // normal downstream message.
    }

    // [START_EXCLUDE]
    /**
     * Production applications would usually process the message here.
     * Eg: - Syncing with server.
     *     - Store message in local database.
     *     - Update UI.
     */
    /*DBHelper dh = DBHelper.getInstance();
    if(dh.getPush(id))
    return;*/
    App.get().getService(IReportService.class).recordPushRecv(id);
    AnalysisUtil.recordPushRecv(id);
    App.get().getService(IRemoteService.class).getSingleNews(id, message, GlobalConfig.SINGLE_NEWS);
    /**
     * In some cases it may be useful to show a notification indicating to the user
     * that a message was received.
     */
    //sendNotification(id, message);
    // [END_EXCLUDE]
}

From source file:com.mozilla.autophone.usbwatchdog.USBService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    long poll_interval;
    mDebug = false;/*www . j av  a 2 s.c o  m*/
    if (intent == null) {
        Log.e("USBWatchdog", "onStartCommand with null intent");
        poll_interval = (long) POLL_INTERVAL;
    } else {
        poll_interval = (long) intent.getIntExtra("poll_interval", POLL_INTERVAL);
        Bundle b = intent.getExtras();
        if (b.toString().indexOf("debug") != -1) {
            mDebug = true;
        }
        Log.i("USBWatchdog", String.format("mDebug: %s", mDebug));
    }

    // Convert the poll interval from the external seconds
    // to milliseconds.
    mServiceHandler.mDebug = mDebug;
    mServiceHandler.mPollInterval = 1000 * poll_interval;

    Message msg = mServiceHandler.obtainMessage();
    msg.arg1 = startId;
    mServiceHandler.sendMessage(msg);

    return START_STICKY;
}

From source file:com.popdeem.sdk.core.gcm.GCMIntentService.java

private void handleMessage(Intent intent) {
    Bundle extras = intent.getExtras();

    final String sender = extras.getString("sender", "");
    if (sender.equalsIgnoreCase(PD_SENDER_VALUE)) {
        PDLog.d(GCMIntentService.class, extras.toString());

        // Get extras
        String title = extras.getString(PD_KEY_TITLE, getString(R.string.app_name));
        String message = extras.getString(PD_KEY_MESSAGE, "");
        String imageUrl = extras.getString(PD_KEY_IMAGE_URL, "");
        String targetUrl = extras.getString(PD_KEY_TARGET_URL, null);
        String deepLink = extras.getString(PD_KEY_DEEP_LINK, null);
        String messageId = extras.getString(PD_KEY_MESSAGE_ID, null);

        // If app is open, show a dialog, else show a notification
        if (PopdeemSDK.currentActivity() != null) {
            if (PopdeemSDK.currentActivity() instanceof FragmentActivity
                    || PopdeemSDK.currentActivity() instanceof AppCompatActivity) {
                FragmentManager fm = ((FragmentActivity) PopdeemSDK.currentActivity())
                        .getSupportFragmentManager();
                PDUINotificationDialogFragment.showNotificationDialog(fm, title, message, imageUrl, targetUrl,
                        deepLink, messageId);
            }/*w  ww.  ja  v a 2  s. co  m*/
        } else {
            // Create Pending Intent for Notification
            PackageManager pm = getPackageManager();
            Intent openAppIntent = pm.getLaunchIntentForPackage(getPackageName());
            openAppIntent.putExtra(PD_NOTIFICATION_INTENT_MESSAGE_ID_KEY, messageId);
            openAppIntent.putExtra(PD_NOTIFICATION_INTENT_URL_KEY, targetUrl != null ? targetUrl : deepLink);
            openAppIntent.putExtra(PD_NOTIFICATION_INTENT_IMAGE_URL_KEY, imageUrl);
            openAppIntent.putExtra(PD_NOTIFICATION_INTENT_TITLE_KEY, title);
            openAppIntent.putExtra(PD_NOTIFICATION_INTENT_MESSAGE_KEY, message);

            PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, openAppIntent, 0);

            int id = (int) PDNumberUtils.toLong(messageId, 1);
            sendNotification(title, message, pendingIntent, id);
        }
    }
}

From source file:com.trams.azit.gcm.MyGcmListenerService.java

/**
 * Called when message is received./*w w  w .j a v  a2 s.  c o 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().
 */
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {
    String message = data.getString("message");
    String code = data.getString("code");
    Log.d(TAG, "From: " + from);
    Log.d(TAG, "Message: " + message);
    Log.d(TAG, "data: " + data.toString());

    if (from.startsWith("/topics/")) {
        // message received from some topic.
    } else {
        // normal downstream message.
    }

    // [START_EXCLUDE]
    /**
     * Production applications would usually process the message here.
     * Eg: - Syncing with server.
     *     - Store message in local database.
     *     - Update UI.
     */

    /**
     * In some cases it may be useful to show a notification indicating to the user
     * that a message was received.
     */
    sendNotification(message, code);
    // [END_EXCLUDE]
}

From source file:com.example.etsmith.gcmupstream.MyGcmListenerService.java

@Override
public void onMessageReceived(String from, final Bundle data) {
    super.onMessageReceived(from, data);

    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {
        public void run() {
            Toast.makeText(getApplicationContext(), "Message Received: " + data.toString(), Toast.LENGTH_SHORT)
                    .show();/*  ww w .  j ava 2  s  .com*/
        }
    });

    for (String dataTag : data.keySet()) {
        if (!dataTag.equals(Constants.NOTIFICATION_BUNDLE)) {
            Log.d(TAG, dataTag + ": " + data.getString(dataTag));
        } else {
            Bundle bundle = data.getBundle(dataTag);
            for (String bundleTag : bundle.keySet()) {
                Log.d(TAG, bundleTag + ": " + data.getString(bundleTag));
            }
        }
    }

    String action = data.getString(Constants.ACTION);
    String status = data.getString(Constants.STATUS);

    if (Constants.REGISTER_NEW_CLIENT.equals(action) && Constants.STATUS_REGISTERED.equals(status)) {
        Log.d(TAG, "Registration Success");
    } else if (Constants.UNREGISTER_CLIENT.equals(action) && Constants.STATUS_UNREGISTERED.equals(status)) {
        //            token = "";
        Log.d(TAG, "Unregistration Success");
    } else if (from.startsWith(Constants.TOPIC_ROOT)) {
        Log.d(TAG, "Topic message: " + data.toString());
    } else {
        Log.d(TAG, "Other type of action: " + data.toString());
    }
}

From source file:com.kakao.game.sample.push.GcmIntentService.java

/**
 * ? ? ? ? ? ,  ? wake lock .//from   w w  w. j av  a 2  s .  c  om
 * @param intent  ?   intent.
 */
@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    String messageType = gcm.getMessageType(intent);

    Logger.e("onHandleIntent()");
    if (!extras.isEmpty()) {
        Logger.i(messageType + " - " + extras.toString());
        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)) {
            sendNotification("Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.thesunsoft.bevy.PickerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pickers);

    Bundle args = getIntent().getExtras();
    if (args != null)
        Log.i(TAG, "args->" + args.toString());

    FragmentManager manager = getSupportFragmentManager();
    Fragment fragmentToShow = null;/*from  w  w  w .j a  va2 s.  c om*/
    Uri intentUri = getIntent().getData();
    if (intentUri != null)
        Log.i(TAG, "intentUri->" + intentUri.toString());
    if (FRIEND_PICKER.equals(intentUri)) {
        if (savedInstanceState == null) {
            friendPickerFragment = new FriendPickerFragment(args);
        } else {
            friendPickerFragment = (FriendPickerFragment) manager.findFragmentById(R.id.picker_fragment);
            ;
        }

        friendPickerFragment.setOnErrorListener(new PickerFragment.OnErrorListener() {
            @Override
            public void onError(PickerFragment<?> fragment, FacebookException error) {
                PickerActivity.this.onError(error);
            }
        });
        friendPickerFragment.setOnDoneButtonClickedListener(new PickerFragment.OnDoneButtonClickedListener() {
            @Override
            public void onDoneButtonClicked(PickerFragment<?> fragment) {
                finishActivity();
            }
        });
        fragmentToShow = friendPickerFragment;

    } else if (PLACE_PICKER.equals(intentUri)) {
        if (savedInstanceState == null) {
            placePickerFragment = new PlacePickerFragment(args);
        } else {
            placePickerFragment = (PlacePickerFragment) manager.findFragmentById(R.id.picker_fragment);
        }
        placePickerFragment.setOnSelectionChangedListener(new PickerFragment.OnSelectionChangedListener() {
            @Override
            public void onSelectionChanged(PickerFragment<?> fragment) {
                finishActivity(); // call finish since you can only pick one place
            }
        });
        placePickerFragment.setOnErrorListener(new PickerFragment.OnErrorListener() {
            @Override
            public void onError(PickerFragment<?> fragment, FacebookException error) {
                PickerActivity.this.onError(error);
            }
        });
        placePickerFragment.setOnDoneButtonClickedListener(new PickerFragment.OnDoneButtonClickedListener() {
            @Override
            public void onDoneButtonClicked(PickerFragment<?> fragment) {
                finishActivity();
            }
        });
        fragmentToShow = placePickerFragment;
    } else {
        // Nothing to do, finish
        setResult(RESULT_CANCELED);
        finish();
        return;
    }

    manager.beginTransaction().replace(R.id.picker_fragment, fragmentToShow).commit();
}

From source file:org.gluu.com.ox_push2.push.PushNotificationService.java

@Override
public void onMessageReceived(String from, Bundle data) {
    String title = data.getString("title");
    String message = data.getString("message");
    setPushData(message);/* w  w w  . ja v  a 2  s  . c o  m*/
    if (Utils.isEmpty(title) || Utils.isEmpty(message)) {
        Log.e(TAG, "Get unknown push notification message: " + data.toString());
        return;
    }

    //        if (GluuApplication.isIsAppInForeground()){
    ////            Intent intent = new Intent(this, GluuMainActivity.class);
    ////            intent.putExtra(GluuMainActivity.QR_CODE_PUSH_NOTIFICATION_MESSAGE, message);
    ////            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    ////            sendNotification(intent, "Authentication login request");
    ////            startActivity(intent);
    //            Intent intent = new Intent(GluuMainActivity.QR_CODE_PUSH_NOTIFICATION);
    //            intent.putExtra(GluuMainActivity.QR_CODE_PUSH_NOTIFICATION_MESSAGE, message);
    //            LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
    //        } else {
    sendNotification("Authentication login request", message);
    //        }
}

From source file:au.com.websitemasters.schools.lcps.push.MyGcmListenerService.java

/**
 * Called when message is received./*w ww. j  a  v a  2 s  .c o 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().
 */
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {
    String message = data.getString("message");

    Log.d("rklogs", "data.toString()_" + data.toString());

    Log.d("rklogs", "From: " + from);
    Log.d("rklogs", "Message: " + message);

    if (from.startsWith("/topics/")) {

        Log.d("rklogs", "message received from some topic.");
    } else {

        Log.d("rklogs", "normal downstream message.");
    }

    // [START_EXCLUDE]
    /**
     * Production applications would usually process the message here.
     * Eg: - Syncing with server.
     *     - Store message in local database.
     *     - Update UI.
     */

    /**
     * In some cases it may be useful to show a notification indicating to the user
     * that a message was received.
     */
    try {

        if ((data.getString("catid").equals("8"))) {
            if (((SchoolsApplication) getApplicationContext()).getSetting("News") == true) {
                sendNotification(message, NewsMenuActivity.class);
            }
        }

        if (data.getString("catid").equals("20")) {
            if (((SchoolsApplication) getApplicationContext()).getSetting("Pre-Kindy") == true) {
                sendNotification(message, AlertsMenuActivity.class);
            }
        }

        if (data.getString("catid").equals("21")) {
            if (((SchoolsApplication) getApplicationContext()).getSetting("Kindy") == true) {
                sendNotification(message, AlertsMenuActivity.class);
            }
        }

        if (data.getString("catid").equals("22")) {
            if (((SchoolsApplication) getApplicationContext()).getSetting("Pre-Primary") == true) {
                sendNotification(message, AlertsMenuActivity.class);
            }
        }

        if (data.getString("catid").equals("23")) {
            if (((SchoolsApplication) getApplicationContext()).getSetting("Year1") == true) {
                sendNotification(message, AlertsMenuActivity.class);
            }
        }

        if (data.getString("catid").equals("24")) {
            if (((SchoolsApplication) getApplicationContext()).getSetting("Year2") == true) {
                sendNotification(message, AlertsMenuActivity.class);
            }
        }

        if (data.getString("catid").equals("25")) {
            if (((SchoolsApplication) getApplicationContext()).getSetting("Year3") == true) {
                sendNotification(message, AlertsMenuActivity.class);
            }
        }

        if (data.getString("catid").equals("26")) {
            if (((SchoolsApplication) getApplicationContext()).getSetting("Year4") == true) {

                sendNotification(message, AlertsMenuActivity.class);
            }
        }

        if (data.getString("catid").equals("27")) {
            if (((SchoolsApplication) getApplicationContext()).getSetting("Year5") == true) {

                sendNotification(message, AlertsMenuActivity.class);
            }
        }

        if (data.getString("catid").equals("28")) {
            if (((SchoolsApplication) getApplicationContext()).getSetting("Year6") == true) {

                sendNotification(message, AlertsMenuActivity.class);
            }
        }

        if (((data.getString("catid").equals("15")) || (data.getString("catid").equals("16"))
                || (data.getString("catid").equals("17")) || (data.getString("catid").equals("18")))) {
            if (((SchoolsApplication) getApplicationContext()).getSetting("Newsletters") == true) {
                sendNotification(message, NewslettersMenuActivity.class);
            }
        }

    } catch (NullPointerException e) {
        Log.d("rklogs", "ER! Nullpointer in MyGCMListener");
    }

    // [END_EXCLUDE]
}

From source file:com.dishcuss.foodie.hub.GCM.MyGcmListenerService.java

/**
 * Called when message is received.//from w  w w. j  a  v a2 s  .  com
 *
 * @param from SenderID of the sender.
 * @param data Data bundle containing message data as key/value pairs.
 *             For Set of keys use data.keySet().
 */
// [START receive_message]

@Override
public void onMessageReceived(String from, Bundle data) {

    String message = data.getString("message");
    String title = data.getString("title");
    String redirect_type = data.getString("redirect_type");
    String redirect_id = data.getString("redirect_id");
    Log.d(TAG, "DATA: " + data.toString());
    Log.d(TAG, "From: " + from);
    Log.d(TAG, "Message: " + message);
    Log.d(TAG, "App: " + title);
    Log.d(TAG, "redirect_type: " + redirect_type);

    handler = new Handler(Looper.getMainLooper());

    int id = Integer.parseInt(redirect_id);
    Log.d(TAG, "redirect_id: " + id);
    sendNotification(message, title, redirect_type, id);
    DishCussApplication app = (DishCussApplication) this.getApplication();
    if (!app.isAppIsInBackground(getApplicationContext())) {
        //            NotificationActivity.newNotifications++;
        //            Log.e("Notifications",""+NotificationActivity.newNotifications);
        //            HomeFragment2.ShowNotifications();
        handler.post(new Runnable() {
            @Override
            public void run() {
                BusProvider.getInstance().post("Notification");
            }
        });
    }
}