List of usage examples for android.os Bundle get
@Nullable
public Object get(String key)
From source file:com.fitticket.model.services.MyGcmListenerService.java
/** * Called when message is received./* ww w .ja 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 type = data.getString("type"); Log.d(TAG, "From: " + from); Log.d(TAG, "Message: " + message); Log.d(TAG, "Notification Type:" + data.get("type")); 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, type); // [END_EXCLUDE] }
From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Activities.MapActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.mapscreen);//from www .j ava 2 s . co m if (savedInstanceState != null) { mapView.setCenter((GeoPoint) savedInstanceState.get("Center")); // TODO restore zoom } }
From source file:fm.smart.r1.CreateExampleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ExceptionHandler.register(this); setContentView(R.layout.create_example); final Intent queryIntent = getIntent(); Bundle extras = queryIntent.getExtras(); item_id = (String) extras.get("item_id"); goal_id = (String) extras.get("goal_id"); if (goal_id == null || goal_id.equals("")) { goal_id = Main.default_study_goal_id; }//www .jav a 2 s. c om cue = (String) extras.get("cue"); example = (String) extras.get("example"); translation = (String) extras.get("translation"); example_language = (String) extras.get("example_language"); translation_language = (String) extras.get("translation_language"); example_transliteration = (String) extras.get("example_transliteration"); translation_transliteration = (String) extras.get("translation_transliteration"); TextView example_text = (TextView) findViewById(R.id.create_example_sentence); if (!TextUtils.isEmpty(example)) { example_text.setText(example); } example_text.setHint(example_language + " sentence with " + cue); TextView translation_text = (TextView) findViewById(R.id.create_example_translation); if (!TextUtils.isEmpty(translation)) { translation_text.setText(translation); } translation_text.setHint(translation_language + " translation of example sentence"); Button button = (Button) findViewById(R.id.create_example_submit); button.setOnClickListener(this); TextView translation_text_legend = (TextView) findViewById(R.id.create_example_translation_legend); TextView sentence_transliteration_textView = (TextView) findViewById( R.id.create_example_sentence_transliteration); EditText sentence_transliteration_input_textView = (EditText) findViewById(R.id.sentence_transliteration); if (!Utils.isIdeographicLanguage(Main.search_lang)) { sentence_transliteration_textView.setVisibility(View.GONE); sentence_transliteration_input_textView.setVisibility(View.GONE); } else if (!TextUtils.isEmpty(example_transliteration)) { sentence_transliteration_input_textView.setText(example_transliteration); } TextView translation_transliteration_textView = (TextView) findViewById( R.id.create_example_translation_transliteration); EditText translation_transliteration_input_textView = (EditText) findViewById( R.id.translation_transliteration); if (!Utils.isIdeographicLanguage(Main.result_lang)) { translation_transliteration_textView.setVisibility(View.GONE); translation_transliteration_input_textView.setVisibility(View.GONE); } else if (!TextUtils.isEmpty(translation_transliteration)) { translation_transliteration_input_textView.setText(translation_transliteration); } }
From source file:com.barelabor.barelabor.gcm.MyGcmListenerService.java
/** * Called when message is received.//from w w w . j a va2 s . co 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) { message = data.getString("data"); title = data.getString("alert"); Log.d(TAG, "message: " + message); Log.d(TAG, "title: " + title); Log.d(TAG, "lowPrice: " + data.get("lowCost")); String repairArrayString = data.getString("repariArray"); String highCostArrayString = data.getString("highCostArray"); String averageCostArrayString = data.getString("averageCostArray"); String lowCostArrayString = data.getString("lowCostArray"); String lowPrice = data.getString("lowCost"); String highPrice = data.getString("highCost"); String avgPrice = data.getString("averageCost"); // [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(repairArrayString, highCostArrayString, averageCostArrayString, lowCostArrayString, lowPrice, highPrice, avgPrice); // [END_EXCLUDE] }
From source file:com.google.firebase.quickstart.fcm.MainActivity.java
private void updateDataTextView(Intent intent) { logDataTextView("BEFORE UPDATE"); restoreDataTextView();/* w w w . j a v a 2 s. co m*/ if (intent != null && intent.getExtras() != null) { Bundle extras = intent.getExtras(); String msg = ""; for (String key : extras.keySet()) { Object value = extras.get(key); if (key.equalsIgnoreCase("google.sent_time") || key.equalsIgnoreCase("from") || key.equalsIgnoreCase("google.message_id") || key.equalsIgnoreCase("collapse_key")) { Log.d(TAG, String.format("Ignored key: %s Value: %s", key, value)); } else { if (msg.isEmpty()) { msg = String.format("Key: %s Value: %s", key, value); } else { msg = String.format("%s\nKey: %s Value: %s", msg, key, value); } } } Log.d(TAG, String.format("Generated message:\n%s", msg)); TextView dataTextView = (TextView) findViewById(R.id.dataTextView); String currentText = (String) dataTextView.getText(); if (currentText.contains("Notification message should be displayed here...")) { dataTextView.setText(msg); } else { dataTextView.setText(String.format("%s\n%s", currentText, msg)); } } saveDataTextView(); logDataTextView("AFTER UPDATE"); }
From source file:com.oodles.smslistener.SmsListenerModule.java
void setupIntentReceivers() { Log.d(LCAT, "inside setupIntentReceivers"); Activity currentActivity = TiApplication.getInstance().getCurrentActivity(); //let's register broadcast receivers BroadcastReceiver smsReceiver = new BroadcastReceiver() { @Override//from ww w . j a v a 2 s. c o m public void onReceive(Context context, Intent intent) { Log.d(LCAT, "inside onReceive"); KrollDict event; switch (getResultCode()) { case Activity.RESULT_OK: final Bundle bundle = intent.getExtras(); try { if (bundle != null) { final Object[] pdusObj = (Object[]) bundle.get("pdus"); for (int i = 0; i < pdusObj.length; i++) { SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]); String phoneNumber = currentMessage.getDisplayOriginatingAddress(); senderNum = phoneNumber; message = currentMessage.getDisplayMessageBody(); } } } catch (Exception e) { Log.e("SmsReceiver", "Exception smsReceiver" + e); } event = createEventObject(true, RECEIVED, message, senderNum); Log.d(LCAT, "message Received"); fireEvent("complete", event); break; default: event = createEventObject(false, FAILED, "Message delivery failed", ""); Log.d(LCAT, "message receiving failure"); fireEvent("complete", event); break; } } }; IntentFilter intentFilter = new IntentFilter(); intentFilter.setPriority(1000); intentFilter.addAction(MESSAGE_RECEIVED); //---when the SMS has been Received--- currentActivity.registerReceiver(smsReceiver, intentFilter); }
From source file:com.google.wireless.speed.speedometer.AccountSelector.java
private void getAuthToken(AccountManagerFuture<Bundle> result) { Log.i(SpeedometerApp.TAG, "getAuthToken() called, result " + result); String errMsg = "Failed to get login cookie. "; Bundle bundle; try {// w w w . j av a 2 s .c o m bundle = result.getResult(); Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT); if (intent != null) { // User input required. (A UI will pop up for user's consent to allow // this app access account information.) Log.i(SpeedometerApp.TAG, "Starting account manager activity"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } else { Log.i(SpeedometerApp.TAG, "Executing getCookie task"); synchronized (this) { this.authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN); this.checkinFuture = checkinExecutor.submit(new GetCookieTask()); } } } catch (OperationCanceledException e) { Log.e(SpeedometerApp.TAG, errMsg, e); throw new RuntimeException("Can't get login cookie", e); } catch (AuthenticatorException e) { Log.e(SpeedometerApp.TAG, errMsg, e); throw new RuntimeException("Can't get login cookie", e); } catch (IOException e) { Log.e(SpeedometerApp.TAG, errMsg, e); throw new RuntimeException("Can't get login cookie", e); } }
From source file:com.android.nsboc.ComposeFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == ComposeActivity.RESULT_OK) { if (requestCode == ComposeActivity.REQUEST_IMAGE_CAPTURE) { Bundle extras = data.getExtras(); Bitmap imageBitmap = (Bitmap) extras.get("data"); int selectorId = data.getIntExtra("image_selector_id", -1); if (selectorId != -1) { TextView selectorLabel = (TextView) mRootView.findViewById(selectorId); if (selectorLabel != null) { Drawable imagePreview = new BitmapDrawable(getResources(), imageBitmap); selectorLabel.setCompoundDrawablesWithIntrinsicBounds(imagePreview, null, null, null); }/*from w ww .ja v a 2 s. c o m*/ } } else if (requestCode == ComposeActivity.REQUEST_FROM_GALLERY || requestCode == ComposeActivity.REQUEST_SIGNATURE) { Uri imageUri = data.getData(); String imagePath = getPath(imageUri); Drawable imagePreview = Drawable.createFromPath(imagePath); int selectorId = data.getIntExtra("image_selector_id", -1); if (selectorId != -1) { TextView selectorLabel = (TextView) mRootView.findViewById(selectorId); if (selectorLabel != null) { selectorLabel.setCompoundDrawablesWithIntrinsicBounds(imagePreview, null, null, null); } } } } }
From source file:com.mta.gcm.GcmIntentService.java
private void handleNotification(Bundle data) { Log.d("MTA", "@GcmIntentService::sendNotification");//#### Intent nextIntent;/*from w w w. jav a2s . c o m*/ nextIntent = new Intent(this, ThreadViewActivity.class); String title = (String) (data.containsKey("mthread") ? data.get("mthread") : "Random Chat"); String message = (String) (data.containsKey("msender") ? data.get("msender") : "Random User"); String time = (String) (data.containsKey("mtime") ? data.get("mtime") : "Random User"); String reference = (String) (data.containsKey("mreference") ? data.get("mreference") : null); if (reference == null) { return; } String realTitle = title + " " + time; String realMessage = "Message from " + message; mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Bundle passData = new Bundle(); passData.putString(THREAD_ID, reference); passData.putString(THREAD_NAME, title); nextIntent.putExtras(passData); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, nextIntent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(realTitle) .setStyle(new NotificationCompat.BigTextStyle().bigText(realMessage)).setAutoCancel(true) .setContentText(realMessage); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); GcmUpdateManager.notifyThreadUpdate(reference, 1); }
From source file:com.baidu.android.voicedemo.ActivityTouch.java
@Override public void onEvent(int eventType, Bundle params) { switch (eventType) { case EVENT_ERROR: String reason = params.get("reason") + ""; print("EVENT_ERROR, " + reason); break;/*from w w w . jav a2 s . c om*/ } }