List of usage examples for android.os Bundle toString
@Override public synchronized String toString()
From source file:app.androidhive.info.realm.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); preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*/*from w w w .j a v a2s.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)) { Log.d(TAG, "Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.d(TAG, "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 title = extras.getString("title", null); String message = extras.getString("description", null); String link = extras.getString("link", null); sendNotification(title, message, link); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.teachmate.teachmate.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 www .ja v 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)) { 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. String info = ""; try { info = DeviceInfoDBHandler.GetValueForKey(getApplication().getApplicationContext(), "DND"); } catch (Exception e) { e.printStackTrace(); } //if(!info.equals("true")){ 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.pushnotificationsapp.app.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 Log.d("RECEIVED MESSAGE", String.valueOf(extras)); try {/*from w w w .j ava 2 s . c om*/ String data = extras.getString("data"); JSONObject obj = new JSONObject(data); the_message = obj.getString("the_message"); String other_parameters = obj.getString("param2"); Log.v("other parameters found", other_parameters); } catch (Exception e) { e.printStackTrace(); } 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(1000); } catch (InterruptedException e) { } } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. sendNotification(the_message); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.arubadesignweb.app.appoverview.util.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 . j a v a 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 (extras.getString("radius") != null && Float.parseFloat(extras.getString("radius")) != 0 && extras.getString("latitude") != null && extras.getString("longitude") != null) { Log.e(TAG, extras.toString()); String target_latitude = extras.getString("latitude"); String target_longitude = extras.getString("longitude"); double target_radius = Double.parseDouble(extras.getString("radius")) * 1000; Location target_location = new Location("target"); target_location.setLatitude(Double.parseDouble(target_latitude)); target_location.setLongitude(Double.parseDouble(target_longitude)); Log.e(TAG, "TargetLocation: " + target_location); if (CommonUtilities.isInsideLocation(this, null, target_location, target_radius)) { Log.e(TAG, "isInsideRegion, send push notification"); sendNotificationSuccess(extras); } else { addProximityAlert(extras, target_location, target_radius); } } else { Log.e("NORMAL", "normal notif"); 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. sendNotificationSuccess(extras); Log.i(TAG, "Received: " + extras.toString()); } } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.endiansoftware.echo.remotewatch.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. j a v a 2s. 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)) { // This loop represents the service doing some work. Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. sendNotification(extras); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.meiste.greg.ptw.gcm.GcmIntentService.java
@Override protected void onHandleIntent(final Intent intent) { final Bundle extras = intent.getExtras(); final GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); final String messageType = gcm.getMessageType(intent); synchronized (mSync) { if (mContainer == null) { try { mSync.wait();/*from www. j a v a 2 s. co m*/ } catch (final InterruptedException e) { } } } if (!extras.isEmpty()) { /* * 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 * not recognized. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { Util.log("GCM send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Util.log("GCM deleted messages on server: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { if (intent.hasExtra(MSG_KEY)) { final String message = intent.getStringExtra(MSG_KEY); Util.log("Received " + message + " message from GCM"); if (MSG_KEY_SYNC.equals(message)) { getFromServer("schedule", scheduleListener, false); getFromServer("standings", standingsListener, true); } else if (MSG_KEY_HISTORY.equals(message)) { getFromServer("history", historyListener, true); } else if (MSG_KEY_RULES.equals(message)) { getFromServer("rule_book", rulesListener, false); } else { Util.log("Message type unknown. Ignoring..."); } } } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:org.android.gcm.client.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { final SharedPreferences prefs = getSharedPreferences("gcmclient", Context.MODE_PRIVATE); pushpak = prefs.getString("push_pak", ""); pushact = prefs.getString("push_act", ""); final boolean pushon = prefs.getBoolean("push_on", true); final boolean pushnotif = prefs.getBoolean("push_notification", true); if (pushnotif) { final String notifact = prefs.getString("notification_act", ""); 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); // Send a notification. if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*/*from www.j a v a 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_SEND_ERROR.equals(messageType)) { sendNotification(getString(R.string.send_error) + ": " + extras.toString(), notifact); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification(getString(R.string.deleted) + ": " + extras.toString(), notifact); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // Post notification of received message. sendNotification( getString(R.string.received, extras.getString("name"), extras.getString("num")), notifact); Log.i(TAG, "Received: " + extras.toString()); } } } // End if push is not enabled. if (!pushon) { // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); return; } final boolean fullwake = prefs.getBoolean("full_wake", false); final boolean endoff = prefs.getBoolean("end_off", true); // Manage the screen. PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock mWakeLock = mPowerManager .newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG); boolean misScreenOn = mPowerManager.isScreenOn(); int mScreenTimeout = 0; if (!misScreenOn) { if (endoff) { // Change the screen timeout setting. mScreenTimeout = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 0); if (mScreenTimeout != 0) { Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 3000); } } // Full wake lock if (fullwake) { mWakeLock.acquire(); } } // Start the activity. try { startActivity(getPushactIntent(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)); // Wait to register. Thread.sleep(REGISTER_DURATION); } catch (android.content.ActivityNotFoundException e) { RING_DURATION = 0; Log.i(TAG, "Activity not started"); } catch (InterruptedException e) { } // Release the wake lock. if (!misScreenOn && fullwake) { mWakeLock.release(); } GcmBroadcastReceiver.completeWakefulIntent(intent); // Restore the screen timeout setting. if (endoff && mScreenTimeout != 0) { try { Thread.sleep(RING_DURATION); } catch (InterruptedException e) { } Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, mScreenTimeout); } }
From source file:com.example.wojtekswiderski.woahpaper.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); word = extras.get("word").toString(); sender = extras.get("sender").toString(); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*/* w w w . j av a 2s .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()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { int results = numberResults(); if (results > MAXRESULTS) { int start; int i = 0; do { start = (int) (Math.random() * MAXRESULTS); i++; } while (setWallPaper(start) && i <= 10); } else { int i = 0; do { i++; } while (setWallPaper(i) && i <= 10); } sendNotification("Received " + word.substring(0, 1).toUpperCase() + word.substring(1) + " from " + sender.substring(0, 1).toUpperCase() + sender.substring(1)); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.landa.backend.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); String usertype = intent.getStringExtra("user"); String action = intent.getStringExtra("action"); 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 . ja va2s.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_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. //Log.i(TAG, "Message is" + usertype + action); for (int i = 0; i < 5; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(250); } catch (InterruptedException e) { } } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. // TODO: add other users if (usertype.equals("cook")) { Log.i(TAG, "Sending to cook activity"); CookOrderToActivity(); } if (usertype.equals("waitstaff")) { if (action.equals("refill")) { String table = intent.getStringExtra("table"); RefillToActivity(table); sendNotification("Table " + table + " would like a refill.", table); } if (action.equals("help")) { String table = intent.getStringExtra("table"); HelpToActivity(table); sendNotification("Table " + table + " requests help.", table); } if (action.equals("refresh")) { RefreshWait(); } } if (usertype.equals("customer")) { if (action.equals("readytopay")) { readyToPay(); } if (action.equals("chat")) { String tableFrom = intent.getStringExtra("tableFrom"); String msg = intent.getStringExtra("msg"); chat(tableFrom, msg); } } Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReciever.completeWakefulIntent(intent); }
From source file:com.smashedin.smashedin.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 a v 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()); } 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 groupType = extras.getString("instanttype", "text"); String uniqueid = extras.getString("uniqueid", "theju"); if (groupType.equals("delete")) { MyGroupDataSingleton.getInstance().RemoveGroup(uniqueid); } else if (groupType.equals("request")) { String bname = extras.getString("bname", ""); String username = extras.getString("username", ""); uniqueid = extras.getString("uniqueid", ""); Intent groupintent = new Intent("group-accept-event"); groupintent.putExtra("uniqueid", uniqueid); groupintent.putExtra("bname", bname); groupintent.putExtra("username", username); LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(groupintent); } else if (uniqueid.contains("theju") != true) { Singleton.getInstance().m_strMessageGcm = extras.getString("live", ""); Singleton.getInstance().m_strMessageGcmUser = extras.getString("username", ""); Singleton.getInstance().m_strMessageGcmBid = extras.getString("bid", ""); Singleton.getInstance().m_strMessageGcmBname = extras.getString("bname", ""); Singleton.getInstance().m_strMessageGcmLocation = extras.getString("atplace", ""); Singleton.getInstance().m_iMessageGcmTimestamp = Long.valueOf(extras.getString("timestamp")) .longValue(); Singleton.getInstance().m_strMessageType = extras.getString("instanttype", "text"); Singleton.getInstance().m_strOhUrl = extras.getString("ohurl", ""); Singleton.getInstance().uniqueid = uniqueid; // This loop represents the service doing some work. // Post notification of received message. //sendNotification("Received: " + extras.toString()); Intent pushintent = new Intent("push-group-event"); LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(pushintent); } else { Singleton.getInstance().m_strMessageGcm = extras.getString("live", ""); Singleton.getInstance().m_strMessageGcmUser = extras.getString("username", ""); Singleton.getInstance().m_strMessageGcmBid = extras.getString("bid", ""); Singleton.getInstance().m_strMessageGcmBname = extras.getString("bname", ""); Singleton.getInstance().m_strMessageGcmLocation = extras.getString("atplace", ""); Singleton.getInstance().m_iMessageGcmTimestamp = Long.valueOf(extras.getString("timestamp")) .longValue(); Singleton.getInstance().m_strMessageType = extras.getString("instanttype", "text"); Singleton.getInstance().m_strOhUrl = extras.getString("ohurl", ""); // This loop represents the service doing some work. // Post notification of received message. //sendNotification("Received: " + extras.toString()); Intent pushintent = new Intent("push-event"); LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(pushintent); } } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }