List of usage examples for android.os Bundle getString
@Nullable
public String getString(@Nullable String key)
From source file:com.easyauth.EasyAuth.GCMIntentService.java
@Override protected void onMessage(Context ctxt, Intent message) { Bundle extras = message.getExtras(); for (String key : extras.keySet()) { Log.d(getClass().getSimpleName(), String.format("onMessage: %s=%s", key, extras.getString(key))); }/* ww w . ja va2 s . co m*/ sendNotification(extras); }
From source file:net.idlesoft.android.apps.github.activities.FileViewer.java
@Override protected void onRestoreInstanceState(final Bundle savedInstanceState) { mHtml = savedInstanceState.getString("html"); if (mHtml != null) { ((WebView) findViewById(R.id.wv_fileView_contents)).loadData(mHtml, "text/html", "UTF-8"); }//from ww w.j a v a 2s . c om super.onRestoreInstanceState(savedInstanceState); }
From source file:com.onesignal.example.OneSignalBackgroundDataReceiver.java
public void onReceive(Context context, Intent intent) { Bundle dataBundle = intent.getBundleExtra("data"); try {// w w w . j a va 2 s . com //Log.i("OneSignalExample", "NotificationTable content: " + dataBundle.getString("alert")); Log.i("OneSignalExample", "NotificationTable title: " + dataBundle.getString("title")); Log.i("OneSignalExample", "Is Your App Active: " + dataBundle.getBoolean("isActive")); Log.i("OneSignalExample", "data addt: " + dataBundle.getString("custom")); JSONObject customJSON = new JSONObject(dataBundle.getString("custom")); if (customJSON.has("a")) Log.i("OneSignalExample", "additionalData:key_a: " + customJSON.getJSONObject("a").getString("a")); } catch (Throwable t) { t.printStackTrace(); } }
From source file:club.frickel.feelathome.DeviceFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle arguments = getArguments(); if (arguments != null) { deviceID = arguments.getString(Constants.DEVICE_ID); }/* w w w . j a v a 2 s . c o m*/ updateEffectsFragment(new ArrayList<Effect>()); new EffectsHandler().execute(); }
From source file:edu.csh.coursebrowser.SectionInfoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_section_info); Bundle args = this.getIntent().getExtras(); this.args = args.getString("args"); this.setTitle(args.getString("title")); Log.v("Sections", args.getString("args")); // Set up the action bar to show tabs. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // For each of the sections in the app, add a tab to the action bar. actionBar.addTab(actionBar.newTab().setText("All").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Non-Full").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Full").setTabListener(this)); }
From source file:com.getmarco.weatherstationviewer.gcm.StationGcmListenerService.java
/** * Called when message is received.// 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) { String message = data.getString("message"); Log.d(LOG_TAG, "From: " + from); Log.d(LOG_TAG, "Message: " + message); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); boolean enableTempNotifications = sharedPreferences .getBoolean(getString(R.string.pref_enable_temp_notifications_key), Boolean.parseBoolean("true")); boolean enableHumidityNotifications = sharedPreferences.getBoolean( getString(R.string.pref_enable_humidity_notifications_key), Boolean.parseBoolean("true")); boolean notifyUser = false; String tag = null; double temp = 0; double humidity = 0; double latitude = 0; double longitude = 0; String dateString = null; StringBuilder msg = new StringBuilder(); try { JSONObject json = new JSONObject(message); if (!json.isNull(STATION_TAG)) { tag = json.getString(STATION_TAG); msg.append(tag); } else throw new IllegalArgumentException("station tag is required"); if (!json.isNull(CONDITION_DATE)) dateString = json.getString(CONDITION_DATE); else throw new IllegalArgumentException("date is required"); if (msg.length() > 0) msg.append(" -"); if (!json.isNull(CONDITION_TEMP)) { notifyUser |= enableTempNotifications; temp = json.getDouble(CONDITION_TEMP); msg.append(" temp: " + getString(R.string.format_temperature, temp)); } if (!json.isNull(CONDITION_HUMIDITY)) { notifyUser |= enableHumidityNotifications; humidity = json.getDouble(CONDITION_HUMIDITY); msg.append(" humidity: " + getString(R.string.format_humidity, humidity)); } if (!json.isNull(CONDITION_LAT)) { latitude = json.getDouble(CONDITION_LAT); } if (!json.isNull(CONDITION_LONG)) { longitude = json.getDouble(CONDITION_LONG); } } catch (JSONException e) { Log.e(LOG_TAG, "error parsing GCM message JSON", e); } long stationId = addStation(tag); Date date = Utility.parseDateDb(dateString); ContentValues conditionValues = new ContentValues(); conditionValues.put(StationContract.ConditionEntry.COLUMN_STATION_KEY, stationId); conditionValues.put(StationContract.ConditionEntry.COLUMN_TEMP, temp); conditionValues.put(StationContract.ConditionEntry.COLUMN_HUMIDITY, humidity); conditionValues.put(StationContract.ConditionEntry.COLUMN_LATITUDE, latitude); conditionValues.put(StationContract.ConditionEntry.COLUMN_LONGITUDE, longitude); conditionValues.put(StationContract.ConditionEntry.COLUMN_DATE, date != null ? date.getTime() : 0); getContentResolver().insert(StationContract.ConditionEntry.CONTENT_URI, conditionValues); /** * show a notification indicating to the user that a message was received. */ if (notifyUser) sendNotification(msg.toString()); }
From source file:it.unipr.ce.dsg.gamidroid.activities.BuildingLookupActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.building_lookup); mContext = this; overridePendingTransition(R.anim.animate_left_in, R.anim.animate_left_out); Button backButton = (Button) findViewById(R.id.backButtonLookup); backButton.setOnClickListener(new View.OnClickListener() { @Override// w w w.j a v a 2 s . c om public void onClick(View v) { GamiNode.getAndroidGamiNode(mContext).getRfm().stopBuildingNotificationLookup(); onBackPressed(); } }); Bundle b = this.getIntent().getExtras(); address = b.getString("AddressBuilding"); Log.d(BuildingLookupActivity.TAG, "Address: " + address); titleTv = (TextView) findViewById(R.id.BuildingText); String addressToShow = address; if (addressToShow.length() > 28) addressToShow = addressToShow.substring(0, 28) + "..."; titleTv.setText(address); titleTv.setTextSize(18); GamiNode.getAndroidGamiNode(mContext).getRfm().startBuildingNotificationLookup(address); SharedPreferences sharedPreferences = mContext.getSharedPreferences(Constants.PREFERENCES, Context.MODE_PRIVATE); String currentNetwork = sharedPreferences.getString(Constants.NETWORK, ""); if (currentNetwork.equalsIgnoreCase(Constants.CHORD)) { GamiNode.addChordResourceListener(this); } else if (currentNetwork.equalsIgnoreCase(Constants.MESH)) { GamiNode.addMeshResourceListener(this); } }
From source file:com.newtifry.android.remote.BackendClient.java
private String getAuthToken(Context context, Account account) throws PendingAuthException { String authToken = null;// w ww . jav a 2 s.co m AccountManager accountManager = AccountManager.get(context); try { AccountManagerFuture<Bundle> future = accountManager.getAuthToken(account, "ah", false, null, null); Bundle bundle = future.getResult(); authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN); // User will be asked for "App Engine" permission. if (authToken == null) { // No authorization token - will need to ask permission from user. Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT); if (intent != null) { // User input required context.startActivity(intent); throw new PendingAuthException("Asking user for permission."); } } } catch (OperationCanceledException e) { Log.d(TAG, e.getMessage()); } catch (AuthenticatorException e) { Log.d(TAG, e.getMessage()); } catch (IOException e) { Log.d(TAG, e.getMessage()); } return authToken; }
From source file:com.drawn.drawn.PickFriendsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pick_friends_activity); Bundle extras = getIntent().getExtras(); final String datosJSON = extras.getString("data"); FragmentManager fm = getSupportFragmentManager(); if (savedInstanceState == null) { // First time through, we create our fragment programmatically. final Bundle args = getIntent().getExtras(); friendPickerFragment = new FriendPickerFragment(args); fm.beginTransaction().add(R.id.friend_picker_fragment, friendPickerFragment).commit(); } else {//from ww w.ja v a 2s. c om // Subsequent times, our fragment is recreated by the framework and already has saved and // restored its state, so we don't need to specify args again. (In fact, this might be // incorrect if the fragment was modified programmatically since it was created.) friendPickerFragment = (FriendPickerFragment) fm.findFragmentById(R.id.friend_picker_fragment); } friendPickerFragment.setOnErrorListener(new PickerFragment.OnErrorListener() { @Override public void onError(PickerFragment<?> fragment, FacebookException error) { PickFriendsActivity.this.onError(error); } }); //Se pide el User ID a Facebook Session session = ParseFacebookUtils.getSession(); if (session != null && session.isOpened()) { requestUserID(); } friendPickerFragment.setOnDoneButtonClickedListener(new PickerFragment.OnDoneButtonClickedListener() { @Override public void onDoneButtonClicked(PickerFragment<?> fragment) { // We just store our selection in the Application for other activities to look at. //Application application = getApplication(); //((Object) application).setSelectedUsers(friendPickerFragment.getSelection()); List<GraphUser> batos = friendPickerFragment.getSelection(); //Se suben los datos de la lista a Parse, solo para debugeo ParseUser current = ParseUser.getCurrentUser(); for (int i = 0; i < batos.size(); i++) { ParseObject datos = new ParseObject("Datos"); datos.put("user_id_destino", batos.get(i).getId()); datos.put("destino_nombre", batos.get(i).getName()); datos.put("origen", id_current_user); datos.put("origen_nombre", name_current_user + " " + last_current_user); datos.put("sketchData", datosJSON); datos.saveInBackground(); } setResult(RESULT_OK, null); Intent intent2 = new Intent(getBaseContext(), SentActivity.class); startActivity(intent2); finish(); } }); }
From source file:it.scoppelletti.mobilepower.widget.DateControl.java
protected void onRestoreInstanceState(Bundle savedInstanceState) { myDialogTag = savedInstanceState.getString(DateControl.STATE_DIALOGTAG); myIsEmptyAllowed = savedInstanceState.getBoolean(DateControl.STATE_ISEMPTYALLOWED, true); myIsResetEnabled = savedInstanceState.getBoolean(DateControl.STATE_ISRESETENABLED, false); setValue((SimpleDate) savedInstanceState.getParcelable(DateControl.STATE_VALUE)); myValueControl.setError(savedInstanceState.getCharSequence(DateControl.STATE_ERROR)); }