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.symptomcheck.capstone.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
        /*//  w w w. java 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)) {
            NotificationHelper.sendNotification(getApplicationContext(), NOTIFICATION_ID, "Gcm message",
                    "Send error: " + extras.toString(), MainActivity.class, false, Constants.STRINGS.EMPTY,
                    null);
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            NotificationHelper.sendNotification(getApplicationContext(), NOTIFICATION_ID, "Gcm message",
                    "Deleted messages on server: " + extras.toString(), MainActivity.class, false,
                    Constants.STRINGS.EMPTY, null);
            // If it's a regular GCM message, do some work.
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {

            final String userType = extras.getString(GcmConstants.GCM_EXTRAS_KEY_USERTYPE);
            final String userName = extras.getString(GcmConstants.GCM_EXTRAS_KEY_USERNAME);
            final String action = extras.getString(GcmConstants.GCM_EXTRAS_KEY_ACTION);
            Log.i(TAG, "GCMMessage Received: " + extras.toString() + "=> " + action + "-" + userName + "-"
                    + userType);

            final UserInfo currentLoggedUser = DAOManager.get().getUser();
            UserType userOriginMsg = UserType.valueOf(userType);
            handleTriggerSync(action, userOriginMsg, userName, currentLoggedUser);

            // Post notification of received message.
            //NotificationHelper.sendNotification(getApplicationContext(),NOTIFICATION_ID,
            //       "Gcm message", "Received: " + extras.toString(), MainActivity.class,false, Constants.STRINGS.EMPTY,null);
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:eu.mysmartline.appv3.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  .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_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 rawMessage = extras.getString("data1");
            if (rawMessage != null) {
                /**
                 * This is the place where wee process the message
                 */
                GcmMessage message = decodeMessage(rawMessage);
                processMessage(message);
                Log.i(TAG, "Message receved in GcmIntentService message content = " + rawMessage);
            } else {
                Log.i(TAG, "No message");
            }

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

From source file:com.amazon.rvspeedtest.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Log.i(TAG, "onHandleIntent called");
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);

    String requestId = extras.getString("requestId");
    // 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 a v  a2 s. 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)) {
            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 downloadSpeed = testDownloadSpeed();
            //sendSpeedToServer(downloadSpeed, requestId);

            Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
            // Post notification of received message.
            sendNotification("Received message from Alexa");
            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.sopinet.trazeo.app.chat.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.  ja 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.
         */
        switch (messageType) {
        case GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR:
            sendNotification("Send error: " + extras.toString(), null, null, null, null);
            break;
        case GoogleCloudMessaging.MESSAGE_TYPE_DELETED:
            sendNotification("Deleted messages on server: " + extras.toString(), null, null, null, null);
            // If it's a regular GCM message, do some work.
            break;
        case GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE:
            // Post notification of received message.
            String chatMsg = extras.getString("text");
            String groupId = extras.getString("groupId");
            String time = extras.getString("time");
            String username = extras.getString("username");
            String type = extras.getString("type");

            try {
                sendNotification(groupId, time, type, chatMsg, username);
            } catch (Exception e) {
                e.printStackTrace();
            }
            break;
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.sagar.sunshine.gcm.MyGcmListenerService.java

/**
 * Called when message is received.//  w w  w . java  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) {
    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();
        }
        if ((senderId).equals(from)) {
            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) {
                e.printStackTrace();
            }
        }
        Log.i(TAG, "Received: " + data.toString());
    }
}

From source file:com.spoiledmilk.ibikecph.login.LoginSplashActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(getLayoutId());
    this.savedInstanceState = savedInstanceState;
    btnSkip = (RelativeLayout) findViewById(R.id.btnSkip);
    btnRegister = (RelativeLayout) findViewById(R.id.btnRegister);
    btnFacebookLogin = (Button) findViewById(R.id.btnFacebookLogin);
    textSkip = (TextView) findViewById(R.id.textSkip);
    textRegister = (TextView) findViewById(R.id.textRegister);

    btnLogin = (Button) findViewById(R.id.btnLogin);
    btnLogin.setOnClickListener(new OnClickListener() {

        @Override//from   w  w  w  .  j  a  v a2s. c o  m
        public void onClick(View arg0) {
            disableButtons();
            lg = new LoginDialog();
            lg.createLoginDialog(LoginSplashActivity.this);
        }

    });

    textCreateAccount = (TextView) findViewById(R.id.textCreateAccount);
    textLoginExplanation = (TextView) findViewById(R.id.textLoginExplanation);

    if (handler == null) {
        handler = new Handler(new Handler.Callback() {

            @Override
            public boolean handleMessage(Message msg) {
                Bundle data = msg.getData();
                Boolean success = data.getBoolean("success");
                dismissProgressDialog();
                if (rd != null) {
                    rd.inProgress = false;
                }
                if (success) {
                    String auth_token = data.getString("auth_token");
                    int id = data.getInt("id");
                    if (id < 0) {
                        launchErrorDialog("", "Login failed : " + data.toString());
                    } else {
                        if (auth_token == null || auth_token.equals("") || auth_token.equals("null")) {
                            auth_token = "";
                        }
                        launchMainMapActivity(auth_token, id);
                    }
                } else {
                    String title = "";
                    if (data.containsKey("info_title")) {
                        title = data.getString("info_title");
                    }
                    launchErrorDialog(title, data.getString("info"));
                }
                return true;
            }
        });
    }

    Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);

}

From source file:my.location.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 .ja va2 s .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)) {
            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(extras.getString("message"));
            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.mb.kids_mind.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);
    Log.v(TAG, "messageType" + messageType);
    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*//from   w  w  w .j  av  a  2s  . 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());

            if (PushWakeLock.ScreenOn(this)) {
                Log.v(TAG, "toast");
                mHandler.post(new ToastRunnable("", this));

            } else {
                PushWakeLock.acquireCpuWakeLock(this);

                Bundle bun = new Bundle();
                int start = extras.toString().indexOf("adviceId=");
                int size = extras.toString().length();
                String text = extras.toString().substring(start + 9);
                //int size=text.length();
                text = extras.toString().substring(start + 9, size - 2);
                Log.v(TAG, "text" + text);
                bun.putString("notiMessage", text);

                Intent popupIntent = new Intent(getApplicationContext(), KidsMindNotiActivity.class);
                popupIntent.putExtras(bun);

                PendingIntent pie = PendingIntent.getActivity(getApplicationContext(), 0, popupIntent,
                        PendingIntent.FLAG_ONE_SHOT);
                try {
                    pie.send();
                } catch (CanceledException e) {

                }
                Log.v(TAG, "?");
            }
            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.vis.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    try {//from ww w. ja  v  a2  s  . c o  m
        GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
        utility = new Utility(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
            /*
             * 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.
                String notification = extras.getString("message");
                if (utility.checkInternetConnectivity()) {
                    new WebServiceUtility(getApplicationContext(), Constants.RECIEVE_INFO_TASK, notification);
                }

                sendNotification(notification);
                Log.i(TAG, "Received: " + extras.toString());
            }
        }
    } catch (JsonSyntaxException e) {
        e.printStackTrace();
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:fr.neamar.notiflow.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  .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, we
         * ignore any message types we're not interested in.
         */
        if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
            sendNotification("Notiflow", "Send error: " + extras.toString(), extras);
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            sendNotification("Notiflow", "Deleted messages on server: " + extras.toString(), extras);
            // If it's a regular GCM message, do some work.
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            // Post notification of received message.
            Boolean isSpecial = extras.containsKey("special");
            String flow = extras.getString("flow", "");
            String author = extras.getString("author", "???");
            String content = extras.getString("content", "");

            if (isSpecial) {
                // Wrap content in <em> tag
                sendNotification(flow, "<b>" + author + "</b>: <em>" + content + "</em>", extras);
            } else if (content.startsWith("    ")) {
                sendNotification(flow, "<b>" + author + "</b>: <tt>" + content + "</tt>", extras);
            } else {
                sendNotification(flow, "<b>" + author + "</b>: " + content, extras);
            }
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}