Bundle putInt - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Bundle putInt method.

This code example shows how to use the following methods:putInt
         */ 
        static BoringFragment newInstance(int num) {
            BoringFragment f = new BoringFragment();
 
            // Supply num input as an argument. 
            Bundle args = new Bundle();
            args.putInt("num", num);
            f.setArguments(args);
 
            return f;
        } 
 
        /** 
         * When creating, retrieve this instance's number from its arguments. 
         */ 
        @Override 
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            mNum = getArguments() != null ? getArguments().getInt("num") : 1;
        } 
8
CodeRank
This code example shows how to use the following methods:putInt
public class EditorFragment extends SherlockFragment { 
  private static final String KEY_POSITION="position";
 
  static EditorFragment newInstance(int position) {
    EditorFragment frag=new EditorFragment();
    Bundle args=new Bundle();
 
    args.putInt(KEY_POSITION, position);
    frag.setArguments(args);
 
    return(frag);
  } 
 
  @Override 
  public View onCreateView(LayoutInflater inflater,
                           ViewGroup container,
                           Bundle savedInstanceState) {
    View result=inflater.inflate(R.layout.editor, container, false);
    EditText editor=(EditText)result.findViewById(R.id.editor);
    int position=getArguments().getInt(KEY_POSITION, -1);
8
CodeRank
This code example shows how to use the following methods:putInt
         */ 
        static MyDialogFragment newInstance(int num) {
            MyDialogFragment f = new MyDialogFragment();
 
            // Supply num input as an argument. 
            Bundle args = new Bundle();
            args.putInt("num", num);
            f.setArguments(args);
 
            return f;
        } 
 
        @Override 
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            mNum = getArguments().getInt("num");
 
            // Pick a style based on the num. 
            int style = DialogFragment.STYLE_NORMAL, theme = 0;
            switch ((mNum-1)%6) {
8
CodeRank
This code example shows how to use the following methods:putInt
public class EditorFragment extends SherlockFragment { 
  private static final String KEY_POSITION="position";
 
  static EditorFragment newInstance(int position) {
    EditorFragment frag=new EditorFragment();
    Bundle args=new Bundle();
 
    args.putInt(KEY_POSITION, position);
    frag.setArguments(args);
 
    return(frag);
  } 
 
  @Override 
  public View onCreateView(LayoutInflater inflater,
                           ViewGroup container,
                           Bundle savedInstanceState) {
    View result=inflater.inflate(R.layout.editor, container, false);
    EditText editor=(EditText)result.findViewById(R.id.editor);
    int position=getArguments().getInt(KEY_POSITION, -1);
8
CodeRank
This code example shows how to use the following methods:putBoolean, putInt
    } 
 
    @Override 
    public Bundle onSaveInstanceState() {
        Bundle state = super.onSaveInstanceState();
        state.putInt(YEAR, mDatePicker.getYear());
        state.putInt(MONTH, mDatePicker.getMonth());
        state.putInt(DAY, mDatePicker.getDayOfMonth());
        state.putBoolean(YEAR_OPTIONAL, mDatePicker.isYearOptional());
        return state;
    } 
 
    @Override 
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        int year = savedInstanceState.getInt(YEAR);
        int month = savedInstanceState.getInt(MONTH);
        int day = savedInstanceState.getInt(DAY);
        boolean yearOptional = savedInstanceState.getBoolean(YEAR_OPTIONAL);
        mDatePicker.init(year, month, day, yearOptional, this);
7
CodeRank
This code example shows how to use the following methods:putInt, putString
                throws NetworkErrorException { 
            return super.getAccountRemovalAllowed(response, account);
        } 
 
        private Bundle getCommonResultBundle() {
        	Bundle resultBundle = new Bundle();
            resultBundle.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION);
            resultBundle.putString(AccountManager.KEY_ERROR_MESSAGE, "This is just a workaround, not a real account authenticator");
            return resultBundle;
		} 
 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:putInt
public class EditorFragment extends SherlockFragment { 
  private static final String KEY_POSITION="position";
 
  static EditorFragment newInstance(int position) {
    EditorFragment frag=new EditorFragment();
    Bundle args=new Bundle();
 
    args.putInt(KEY_POSITION, position);
    frag.setArguments(args);
 
    return(frag);
  } 
 
  static String getTitle(Context ctxt, int position) {
    return(String.format(ctxt.getString(R.string.hint), position + 1));
  } 
 
  @Override 
  public View onCreateView(LayoutInflater inflater,
                           ViewGroup container,
8
CodeRank
This code example shows how to use the following methods:putInt
 
	} 
 
	@Override 
	void saveState(Bundle outState) {
		super.saveState(outState);
 
		outState.putInt("cellRow", mCellRow);
		outState.putInt("cellColumn", mCellColumn);
		outState.putInt("value", mValue);
		outState.putInt("oldValue", mOldValue);
	} 
 
	@Override 
	void restoreState(Bundle inState) {
		super.restoreState(inState);
 
		mCellRow = inState.getInt("cellRow");
		mCellColumn = inState.getInt("cellColumn");
		mValue = inState.getInt("value");
8
CodeRank
This code example shows how to use the following methods:putInt, putString
    private static void addEditorInfoToBundle(EditorInfo info, Bundle bundle) {
        if (info == null) {
            return; 
        } 
 
        bundle.putString(LABEL, safeToString(info.label));
        bundle.putString(HINT, safeToString(info.hintText));
        bundle.putString(PACKAGE_NAME, safeToString(info.packageName));
        bundle.putInt(FIELD_ID, info.fieldId);
        bundle.putString(FIELD_NAME, safeToString(info.fieldName));
        bundle.putInt(INPUT_TYPE, info.inputType);
        bundle.putInt(IME_OPTIONS, info.imeOptions);
    } 
 
    @SuppressWarnings("static-access") 
    private static void addInputConnectionToBundle( 
        InputConnection conn, Bundle bundle) {
        if (conn == null) {
            return; 
        } 
8
CodeRank
This code example shows how to use the following methods:putInt, size
    assertEquals(7, bundle.getInt("bar", 7));
  } 
 
  @Test 
  public void testSize() { 
    assertEquals(0, bundle.size());
    bundle.putInt("foo", 5);
    assertEquals(1, bundle.size());
    bundle.putInt("bar", 5);
    assertEquals(2, bundle.size());
  } 
 
  @Test 
  public void testLong() { 
    bundle.putLong("foo", 5);
    assertEquals(5, bundle.getLong("foo"));
    assertEquals(0,bundle.getLong("bar"));
    assertEquals(7, bundle.getLong("bar", 7));
  } 
 
8
CodeRank

Related Bundle putInt Questions & Answers:

putInt Method Overview
Inserts an int value into the mapping of this Bundle, replacing any existing value for the given key.
See Code Examples for other Android Bundle Methods: