Example usage for android.os Bundle putBoolean

List of usage examples for android.os Bundle putBoolean

Introduction

In this page you can find the example usage for android.os Bundle putBoolean.

Prototype

public void putBoolean(@Nullable String key, boolean value) 

Source Link

Document

Inserts a Boolean value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.sweetiepiggy.raspberrybusmalaysia.SubmitTripActivity.java

private void init_map_buttons() {
    Button from_map_button = (Button) findViewById(R.id.from_map_button);
    from_map_button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(getApplicationContext(), RbmMapActivity.class);
            Bundle b = new Bundle();
            b.putBoolean("set_result", true);
            intent.putExtras(b);//from   ww w.  ja  va2  s  .  c  om
            startActivityForResult(intent, ACTIVITY_FROM);
        }
    });

    Button to_map_button = (Button) findViewById(R.id.to_map_button);
    to_map_button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(getApplicationContext(), RbmMapActivity.class);
            Bundle b = new Bundle();
            b.putBoolean("set_result", true);
            intent.putExtras(b);
            startActivityForResult(intent, ACTIVITY_TO);
        }
    });
}

From source file:com.codingrhemes.steamsalesmobile.GameSaleActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gamesaleactivity);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    if (savedInstanceState == null) {
        // Setting up bundle to keep values
        Bundle mostPopGames = new Bundle();
        mostPopGames.putBoolean("isMostPopular", true);
        dailyDealFragment = new DealOfTheDayFragment();
        gamesFragment = new GamesFragment();
        mostPopularFragment = new MostPopularGamesFragment();
        // set them to the fragment
        mostPopularFragment.setArguments(mostPopGames);
    }//from  w w w.  j a  v  a  2s.  c  o m

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

}

From source file:com.googlecode.android_scripting.facade.AndroidFacade.java

private static void putNestedJSONObject(JSONObject jsonObject, Bundle bundle) throws JSONException {
    JSONArray names = jsonObject.names();
    for (int i = 0; i < names.length(); i++) {
        String name = names.getString(i);
        Object data = jsonObject.get(name);
        if (data == null) {
            continue;
        }/*  w w  w  . j a  va  2 s .  c o m*/
        if (data instanceof Integer) {
            bundle.putInt(name, ((Integer) data).intValue());
        }
        if (data instanceof Float) {
            bundle.putFloat(name, ((Float) data).floatValue());
        }
        if (data instanceof Double) {
            bundle.putDouble(name, ((Double) data).doubleValue());
        }
        if (data instanceof Long) {
            bundle.putLong(name, ((Long) data).longValue());
        }
        if (data instanceof String) {
            bundle.putString(name, (String) data);
        }
        if (data instanceof Boolean) {
            bundle.putBoolean(name, ((Boolean) data).booleanValue());
        }
        // Nested JSONObject
        if (data instanceof JSONObject) {
            Bundle nestedBundle = new Bundle();
            bundle.putBundle(name, nestedBundle);
            putNestedJSONObject((JSONObject) data, nestedBundle);
        }
        // Nested JSONArray. Doesn't support mixed types in single array
        if (data instanceof JSONArray) {
            // Empty array. No way to tell what type of data to pass on, so skipping
            if (((JSONArray) data).length() == 0) {
                Log.e("Empty array not supported in nested JSONObject, skipping");
                continue;
            }
            // Integer
            if (((JSONArray) data).get(0) instanceof Integer) {
                int[] integerArrayData = new int[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    integerArrayData[j] = ((JSONArray) data).getInt(j);
                }
                bundle.putIntArray(name, integerArrayData);
            }
            // Double
            if (((JSONArray) data).get(0) instanceof Double) {
                double[] doubleArrayData = new double[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    doubleArrayData[j] = ((JSONArray) data).getDouble(j);
                }
                bundle.putDoubleArray(name, doubleArrayData);
            }
            // Long
            if (((JSONArray) data).get(0) instanceof Long) {
                long[] longArrayData = new long[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    longArrayData[j] = ((JSONArray) data).getLong(j);
                }
                bundle.putLongArray(name, longArrayData);
            }
            // String
            if (((JSONArray) data).get(0) instanceof String) {
                String[] stringArrayData = new String[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    stringArrayData[j] = ((JSONArray) data).getString(j);
                }
                bundle.putStringArray(name, stringArrayData);
            }
            // Boolean
            if (((JSONArray) data).get(0) instanceof Boolean) {
                boolean[] booleanArrayData = new boolean[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    booleanArrayData[j] = ((JSONArray) data).getBoolean(j);
                }
                bundle.putBooleanArray(name, booleanArrayData);
            }
        }
    }
}

From source file:com.bonsai.wallet32.SweepKeyActivity.java

protected DialogFragment showModalDialog(String title, String msg) {
    DialogFragment df = new MyDialogFragment();
    Bundle args = new Bundle();
    args.putString("title", title);
    args.putString("msg", msg);
    args.putBoolean("hasOK", false);
    df.setArguments(args);//w w  w  .  ja v a 2  s.  c o  m
    df.show(getSupportFragmentManager(), "wait");
    return df;
}

From source file:com.android.deskclock.worldclock.CitiesActivity.java

@Override
public void onSaveInstanceState(Bundle bundle) {
    super.onSaveInstanceState(bundle);
    bundle.putString(KEY_SEARCH_QUERY, mQueryTextBuffer.toString());
    bundle.putBoolean(KEY_SEARCH_MODE, mSearchMode);
    bundle.putInt(KEY_LIST_POSITION, mCitiesList.getFirstVisiblePosition());
}

From source file:augsburg.se.alltagsguide.overview.OverviewActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putSerializable(OTHER_LANGUAGES_KEY, new ArrayList<>(mOtherLanguages));
    outState.putBoolean(SAVE_INSTANCE_STATE_NAVIGATION_DRAWER_OPEN,
            drawerLayout.isDrawerOpen(GravityCompat.START));
    super.onSaveInstanceState(outState);
}

From source file:org.elasticdroid.SshConnectorView.java

/**
 * Save state of the activity on destroy/stop.
 * Saves://from   www . ja va  2s  .  com
 * <ul>
 * <li></li>
 * </ul>
 */
@Override
public void onSaveInstanceState(Bundle saveState) {
    // if a dialog is displayed when this happens, dismiss it
    if (alertDialogDisplayed) {
        alertDialogBox.dismiss();
    }
    //save the info as to whether dialog is displayed
    saveState.putBoolean("alertDialogDisplayed", alertDialogDisplayed);
    //save the dialog msg
    saveState.putString("alertDialogMessage", alertDialogMessage);

    //save the list of open ports 
    if (openPorts != null) {
        saveState.putSerializable("openPorts", openPorts);
        saveState.putInt("selectedPortPos",
                ((Spinner) findViewById(R.id.sshConnectorPortSpinner)).getSelectedItemPosition());
    }
    //save if progress dialog is being displayed.
    saveState.putBoolean("progressDialogDisplayed", progressDialogDisplayed);

    //save the username entered if it is not the default user name
    String curUsername = ((EditText) findViewById(R.id.sshConnectorUsernameEditTextView)).getText().toString();
    if (!curUsername.equals(this.getString(R.string.ssh_defaultuser))) {
        saveState.putString("sshUsername", curUsername);
    }

    //save the state of the checkbox that specifies whether pubkey auth should be used or not
    saveState.putBoolean("usePubkeyAuth",
            ((CheckBox) findViewById(R.id.sshConnectorUsePublicKeyAuth)).isChecked());
}

From source file:au.org.ala.fielddata.mobile.MobileFieldDataDashboard.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putInt(SELECTED_TAB_BUNDLE_KEY, getSupportActionBar().getSelectedNavigationIndex());
    outState.putBoolean(GPS_QUESTION_BUNDLE_KEY, askedAboutGPS);
    outState.putBoolean(REDIRECTED_TO_LOGIN_BUNDLE_KEY, redirectedToLogin);
}

From source file:com.affectiva.affdexme.MetricSelectionFragment.java

@Override
public void onSaveInstanceState(Bundle bundle) {
    //save whether each MetricSelector has been selected, using the metric name as the key
    for (MetricsManager.Metrics metric : MetricsManager.getAllMetrics()) {
        bundle.putBoolean(metric.toString(), metricSelectors.get(metric).getIsSelected());
    }/*from w ww.j ava  2 s.  c  o  m*/
    super.onSaveInstanceState(bundle);
}

From source file:ca.mudar.mtlaucasou.BaseMapActivity.java

/**
 * Save the list isHidden() status. {@inheritDoc}
 *///from  w  ww . j a va2  s.co  m
@Override
public void onSaveInstanceState(Bundle outState) {

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragmentList = fm.findFragmentByTag(Const.TAG_FRAGMENT_LIST);
    if (fragmentList != null) {
        /**
         * For visible/hidden fragments and actionbar icon.
         */
        outState.putBoolean(Const.KEY_INSTANCE_LIST_IS_HIDDEN, fragmentList.isHidden());
    }

    super.onSaveInstanceState(outState);
}