RationaleDialogConfig(Bundle bundle) { positiveButton = bundle.getString(KEY_POSITIVE_BUTTON); negativeButton = bundle.getString(KEY_NEGATIVE_BUTTON); rationaleMsg = bundle.getString(KEY_RATIONALE_MESSAGE); theme = bundle.getInt(KEY_THEME); requestCode = bundle.getInt(KEY_REQUEST_CODE); permissions = bundle.getStringArray(KEY_PERMISSIONS); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Bundle args = getArguments(); if (args == null) return; drawableId = args.getInt(ARG_DRAWABLE_ID); title = args.getString(ARG_TITLE); imageView.setImageResource(drawableId); titleView.setText(title); int titleColor = args.getInt(ARG_TITLE_COLOR, WelcomeUtils.NO_COLOR_SET); if (titleColor != WelcomeUtils.NO_COLOR_SET) titleView.setTextColor(titleColor); showParallaxAnim = args.getBoolean(ARG_SHOW_ANIM, showParallaxAnim); WelcomeUtils.setTypeface(titleView, args.getString(ARG_TYPEFACE_PATH), getActivity()); }
private void setAlbumart() { playlistname.setText(getIntent().getExtras().getString(Constants.PLAYLIST_NAME)); foreground.setBackgroundColor(getIntent().getExtras().getInt(Constants.PLAYLIST_FOREGROUND_COLOR)); loadBitmap(TimberUtils.getAlbumArtUri(getIntent().getExtras().getLong(Constants.ALBUM_ID)).toString()); }
@Override public void onSaveInstanceState(Bundle outState) { outState.putString("message", "This is my message to be reloaded"); super.onSaveInstanceState(outState); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { String message = savedInstanceState.getString("message"); Toast.makeText(this, message, Toast.LENGTH_LONG).show(); } }
@Override protected void onViewBound(@NonNull View view) { super.onViewBound(view); tvTitle.setText(getArgs().getString(KEY_TITLE)); int bgColor = getArgs().getInt(KEY_BG_COLOR); if (getArgs().getBoolean(KEY_COLOR_IS_RES)) { bgColor = ContextCompat.getColor(getActivity(), bgColor); } view.setBackgroundColor(bgColor); } }
@Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { String content = getArguments().getString(ARG_C); TextView textView = new TextView(getContext()); textView.setTextSize(30); textView.setGravity(Gravity.CENTER); textView.setText(String.format("Test\n\n%s", content)); textView.setBackgroundColor(0xFFececec); return textView; } }
@Override public View getView(int position, View convertView, ViewGroup parent) { TextView row= (TextView)super.getView(position, convertView, parent); String key=getItem(position); if (RestrictionEntriesReceiver.RESTRICTION_BOOLEAN.equals(key)) { int icon= restrictions.getBoolean(key) ? R.drawable.ic_true : R.drawable.ic_false; row.setCompoundDrawablesWithIntrinsicBounds(0, 0, icon, 0); } else if (RestrictionEntriesReceiver.RESTRICTION_CHOICE.equals(key)) { row.setText(String.format("%s (%s)", key, restrictions.getString(key))); } else { String value= TextUtils.join(" | ", restrictions.getStringArray(key)); row.setText(String.format("%s (%s)", key, value)); } return(row); } }
@Override public Message getDialogHandlerMessage() { Message msg = Message.obtain(); msg.what = DialogHandler.MSG_SHOW_SYNC_ERROR_DIALOG; Bundle b = new Bundle(); b.putInt("dialogType", getArguments().getInt("dialogType")); b.putString("dialogMessage", getArguments().getString("dialogMessage")); msg.setData(b); return msg; }
when(bundle.getDouble(anyString(), anyDouble())).thenAnswer(getOrDefault); doAnswer(put).when(bundle).putString(anyString(), anyString()); when(bundle.getString(anyString())).thenAnswer(get); when(bundle.getString(anyString(), anyString())).thenAnswer(getOrDefault); when(bundle.getInt(anyString())).thenAnswer(get); when(bundle.getInt(anyString(), anyInt())).thenAnswer(getOrDefault);
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case DATEPICKER_FRAGMENT: if (resultCode == Activity.RESULT_OK) { Bundle bundle = data.getExtras(); String mMonth = bundle.getString("month", Month); int mYear = bundle.getInt("year"); Log.i("PICKER", "Got year=" + year + " and month=" + month + ", yay!"); } else if (resultCode == Activity.RESULT_CANCELED) { ... } break; } }
innerBundle2.putString("inner", "2"); innerBundle2.putStringArray("deep list", new String[] {"7", "8"}); b.putLong("longValue", 5000000000l); b.putDouble("doubleValue", 3.14); b.putString("stringValue", "hello world"); b.putStringArray("stringArrayValue", new String[] {"first", "second"}); b.putStringArrayList("stringArrayListValue", arrayList); assertEquals(7, finalBundle.getInt("intValue")); assertEquals(5000000000l, finalBundle.getLong("longValue")); assertEquals(3.14, finalBundle.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA); assertEquals("hello world", finalBundle.getString("stringValue")); assertEquals(1, finalInnerBundle.getInt("inner")); finalBundle = finalInnerBundle.getBundle("nested bundle"); assertEquals("2", finalBundle.getString("inner"));
/* Start Activity */ public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName("com.thinoo.ActivityTest", "com.thinoo.ActivityTest.NewActivity"); startActivityForResult(intent,90); } /* Called when the second activity's finished */ protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch(requestCode) { case 90: if (resultCode == RESULT_OK) { Bundle res = data.getExtras(); String result = res.getString("param_result"); Log.d("FIRST", "result:"+result); } break; } } private void finishWithResult() { Bundle conData = new Bundle(); conData.putString("param_result", "Thanks Thanks"); Intent intent = new Intent(); intent.putExtras(conData); setResult(RESULT_OK, intent); finish(); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment // don't look at this layout it's just a listView to show how to handle the keyboard View view = inflater.inflate(R.layout.fragment_sample, container, false); TextView textView = (TextView) view.findViewById(R.id.title); textView.setText(getArguments().getString(KEY_TITLE)); return view; } }
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.wel_fragment_basic, container, false); Bundle args = getArguments(); imageView = (ImageView) view.findViewById(R.id.wel_image); titleView = (TextView) view.findViewById(R.id.wel_title); descriptionView = (TextView) view.findViewById(R.id.wel_description); if (args == null) return view; showParallaxAnim = args.getBoolean(KEY_SHOW_ANIM, showParallaxAnim); imageView.setImageResource(args.getInt(KEY_DRAWABLE_ID)); if (args.getString(KEY_TITLE) != null) titleView.setText(args.getString(KEY_TITLE)); if (args.getString(KEY_DESCRIPTION) != null) descriptionView.setText(args.getString(KEY_DESCRIPTION)); int headerColor = args.getInt(KEY_HEADER_COLOR, WelcomeUtils.NO_COLOR_SET); if (headerColor != WelcomeUtils.NO_COLOR_SET) titleView.setTextColor(headerColor); int descriptionColor = args.getInt(KEY_DESCRIPTION_COLOR, WelcomeUtils.NO_COLOR_SET); if (descriptionColor != WelcomeUtils.NO_COLOR_SET) descriptionView.setTextColor(descriptionColor); WelcomeUtils.setTypeface(titleView, args.getString(KEY_HEADER_TYPEFACE_PATH), getActivity()); WelcomeUtils.setTypeface(descriptionView, args.getString(KEY_DESCRIPTION_TYPEFACE_PATH), getActivity()); return view; }
@Override public void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); // Restore UI state from the savedInstanceState. // This bundle has also been passed to onCreate. boolean myBoolean = savedInstanceState.getBoolean("MyBoolean"); double myDouble = savedInstanceState.getDouble("myDouble"); int myInt = savedInstanceState.getInt("MyInt"); String myString = savedInstanceState.getString("MyString"); }
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (mImageUri != null) { outState.putString("cameraImageUri", mImageUri.toString()); } } @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); if (savedInstanceState.containsKey("cameraImageUri")) { mImageUri = Uri.parse(savedInstanceState.getString("cameraImageUri")); } }