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:kits.gcmtemplate.gcmServices.MyGcmListenerService.java

/**
 * Called when message is received.//from  ww  w  .ja  va 2  s.  c  om
 *
 * @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) {
    String message = data.getString("message");
    System.out.println(data.toString());

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

    // If you want to handle these messages differently do so here.
    if (from.startsWith("/topics/")) {
        // Message sent to any topic will go here
    } else {
        // Message sent to this device will go here
    }

    handleData(message);
    showNotification(data);
    sendToUserInterface(message);
}

From source file:jp.co.ipublishing.esnavi.impl.gcm.GcmIntentService.java

/**
 * ???/*from  w ww.ja va 2s  .c om*/
 *
 * @param extras ?
 */
@Override
protected void onReceivedErrorMessage(Bundle extras) {
    // Nothing to do
    Log.e(TAG, extras.toString());
}

From source file:jp.co.ipublishing.esnavi.impl.gcm.GcmIntentService.java

/**
 * ???//from  w w  w.  j  a v a 2  s . co m
 *
 * @param extras ?
 */
@Override
protected void onReceivedDeletedMessage(Bundle extras) {
    // Nothing to do
    Log.i(TAG, extras.toString());
}

From source file:com.devbd.cttd.hello_ct.PushPkg.GcmBroadcastReceiver.java

private void sendNotification(Bundle bundle) {

    String msg = bundle.getString("price");

    System.out.println(">>>>>>>>>>FFFF  " + bundle.toString());

    //       String from_name=bundle.getString("From_Name");
    //       String type=bundle.getString("Type");
    //       String params=bundle.getString("Params");

    //       NotificationDetails nd=new NotificationDetails();
    //       nd.setBody(msg);
    //       nd.setFrom_email(from_email);
    //       nd.setFrom_name(from_name);
    //       nd.setFrom_image(from_image);
    //       //from  w ww.j  a  v a  2s  . c  o m

    mNotificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);

    // 
    if (msg != null) {

        Noti.msg = msg;
        PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, new Intent(ctx, Noti.class),
                PendingIntent.FLAG_CANCEL_CURRENT);

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(ctx).setSmallIcon(R.mipmap.icon)
                .setLargeIcon(BitmapFactory.decodeResource(ctx.getResources(), R.mipmap.icon))
                .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                .setContentTitle(ctx.getResources().getString(R.string.app_name)).setAutoCancel(true)
                .setContentText(Html.fromHtml(msg))
                .setStyle(new NotificationCompat.BigTextStyle().bigText(Html.fromHtml(msg)));

        mBuilder.setContentIntent(contentIntent);
        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    }
}

From source file:com.cbtec.eliademy.GCMIntentService.java

@Override
protected void onMessage(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    Log.d(TAG, "Received message" + extras.toString());
    if (extras != null) {
        try {/*from   www  .  ja v a  2  s  .  com*/
            JSONObject json;
            json = new JSONObject().put("event", "notifications");
            json.put("notifications", extras.getString("notifications"));

            Log.v(TAG, json.toString());
            if (GCMPlugin.isActive()) {
                // TODO: Find better way
                JSONObject msgobj = new JSONObject(extras.getString("notifications"));
                String msg = msgobj.getString("author") + " " + msgobj.getString("content") + " for course "
                        + msgobj.getString("coursename");
                generateNotification(context, msg);
                GCMPlugin.sendJavascript(json);
            } else {
                // form message
                JSONObject msgobj = new JSONObject(extras.getString("notifications"));
                String msg = msgobj.getString("author") + " " + msgobj.getString("content") + " for course "
                        + msgobj.getString("coursename");
                generateNotification(context, msg);
            }
        } catch (JSONException e) {
            Log.e(TAG, "JSON exception" + e.getMessage());
        }
    }
}

From source file:com.acdd.homelauncher.fragment.InstalledAppFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mListView = (ListView) view.findViewById(R.id.listView);
    List<org.osgi.framework.Bundle> mm = ACDD.getInstance().getBundles();
    ArrayList<String> list = new ArrayList<String>();
    for (org.osgi.framework.Bundle mObj : mm) {

        System.err.println(mObj.toString());
        list.add(mObj.getLocation());//from ww  w .  j a  va2  s . co  m
    }

    mListView.setAdapter(new ArrayAdapter<String>(getActivity(), R.layout.item_app, android.R.id.text1, list));
    mListView.setOnItemClickListener(this);
}

From source file:com.survtapp.gcm.MyGcmListenerService.java

/**
 * Called when message is received.//from   w  ww  . j  a v  a  2s  .  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().
 */
@Override
public void onMessageReceived(String from, Bundle data) {
    super.onMessageReceived(from, data);
    // notifies user

    Log.d(TAG, data.toString());
    Log.d(TAG, from.toString());

    String msg = data.getString("msg");
    String date = data.getString("date");
    String title = data.getString("title");
    String url = data.getString("image_url");
    insertIntoDataBase(title, msg, date, url);

    try {
        showNotification(msg, url, title);

    } catch (Exception e) {
    }

    /*Intent downstreamMessageIntent = new Intent(RegistrationConstants.NEW_DOWNSTREAM_MESSAGE);
    downstreamMessageIntent.putExtra(RegistrationConstants.SENDER_ID, from);
    downstreamMessageIntent.putExtra(RegistrationConstants.EXTRA_KEY_BUNDLE, data);
    LocalBroadcastManager.getInstance(this).sendBroadcast(downstreamMessageIntent);*/
}

From source file:vn.easycare.GCMIntentService.java

@Override
protected void onMessage(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();
    Log.e(TAG, "Received message for Device. Extras: " + bundle.toString());
    Log.e(TAG, "Received message for Device Device");
    // Process message later
    String message = bundle.getString("msg_content", "");
    mNotifyCount = Integer.parseInt(bundle.getString("count", "0"));
    Log.e(TAG, "Received message for Device Device" + message);
    Log.e(TAG, "Received count for Device Device" + mNotifyCount);
    generateNotification(context, message);
    // Also update notify count
    updateNotifyLayoutWhenAppRunningForeground(context);
}

From source file:com.gcm.lib.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()) {
        sendNotification(extras.toString(), messageType);
    }//from   w  w  w  .j  ava2 s.c  om
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:services.MyGcmListenerService.java

/**
 * Called when message is received./*from   w w  w  . j a v  a 2s . 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) {
    Log.d("data from gcm", data.toString());
    final String message = data.getString("message");
    String title = data.getString("title");
    Log.d(TAG, "From: " + from);
    Log.d(TAG, "Message: " + message);

    try {
        final JSONObject gcmSentMessage = new JSONObject(message);

        SharedPreferences prefs = getSharedPreferences("cache", Context.MODE_PRIVATE);
        JSONObject profile = new JSONObject(prefs.getString("profile", null));
        Log.d("profile-user", profile.toString());
        Log.d("profile-user", profile.getInt("profile_id") + "");
        if (gcmSentMessage.has("from_id")) {
            // return;
        } else if (gcmSentMessage.has("to_profile_id") && gcmSentMessage.getString("to_profile_id").trim()
                .toLowerCase().contentEquals(profile.getString("profile_id").trim().toLowerCase())) {
            /*
            update the adapter ::start
             */
            ChatActivity.activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    try {
                        LayoutInflater layoutInflater = LayoutInflater.from(ChatActivity.activity);
                        View view = layoutInflater.inflate(R.layout.chat_list_item_2, ChatActivity.chatListView,
                                false);
                        ((TextView) view.findViewById(R.id.message))
                                .setText(new JSONObject(message).getJSONObject("message").getString("data"));
                        ChatActivity.chatListView.addView(view);
                        Log.d("message", "a new message inside ui thread");
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
            Log.d("message", "a new message");

            // return;

            /*
            update the adapter ::send
             */
            //                MyNotification myNotification = new MyNotification(message);
            //                myNotification.save();
            //
            //                sendNotification(message, title);
        } else if (new JSONObject(gcmSentMessage.getString("profile_user").replace("\\", ""))
                .getInt("profile_id") == profile.getInt("profile_id")) {

            MyNotification myNotification = new MyNotification(message);

            myNotification.save();

            sendNotification(message, title);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    /**
     * 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.
     */

}