Example usage for android.os Bundle getBoolean

List of usage examples for android.os Bundle getBoolean

Introduction

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

Prototype

public boolean getBoolean(String key) 

Source Link

Document

Returns the value associated with the given key, or false if no mapping of the desired type exists for the given key.

Usage

From source file:com.hybris.mobile.lib.commerce.sync.CatalogSyncAdapter.java

@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
        SyncResult syncResult) {//from   www .j  av a2 s  . co m

    Log.i(TAG, "Receiving a sync with bundle: " + extras.toString());

    // Get some optional parameters
    String categoryId = extras.getString(CatalogSyncConstants.SYNC_PARAM_GROUP_ID);
    String productId = extras.getString(CatalogSyncConstants.SYNC_PARAM_DATA_ID);
    boolean loadVariants = extras.getBoolean(CatalogSyncConstants.SYNC_PARAM_LOAD_VARIANTS);
    String contentServiceHelperUrl = extras
            .getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_URL);
    boolean cancelAllRequests = extras.getBoolean(CatalogSyncConstants.SYNC_PARAM_CANCEL_ALL_REQUESTS);

    // Update the content service helper url
    if (StringUtils.isNotBlank(contentServiceHelperUrl)) {
        String catalog = extras.getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_CATALOG);
        String catalogId = extras.getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_CATALOG_ID);
        String catalogVersionId = extras
                .getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_CATALOG_VERSION_ID);
        String catalogMainCategoryId = extras
                .getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_MAIN_CATEGORY_ID);
        updateContentServiceHelperUrlConfiguration(contentServiceHelperUrl, catalog, catalogId,
                catalogVersionId, catalogMainCategoryId);
    }
    // Cancelling all the requests
    else if (cancelAllRequests) {
        cancelAllRequests();
    }
    // Sync a category
    else if (StringUtils.isNotBlank(categoryId)) {
        Log.i(TAG, "Syncing the category " + categoryId);

        int currentPage = 0;
        int pageSize = 0;

        if (extras.containsKey(CatalogSyncConstants.SYNC_PARAM_CURRENT_PAGE)
                && extras.containsKey(CatalogSyncConstants.SYNC_PARAM_PAGE_SIZE)) {
            currentPage = extras.getInt(CatalogSyncConstants.SYNC_PARAM_CURRENT_PAGE);
            pageSize = extras.getInt(CatalogSyncConstants.SYNC_PARAM_PAGE_SIZE);
        }

        syncCategory(categoryId, currentPage, pageSize);

    }
    // Sync a product
    else if (StringUtils.isNotBlank(productId)) {
        Log.i(TAG, "Syncing the product " + productId);

        loadProduct(productId, categoryId, null, false, loadVariants);
    }
    // Sync all the catalog
    else {
        Log.i(TAG, "Syncing the catalog");

        // Init nb calls counter and blocker
        mNbCalls = new AtomicInteger();
        mBlockSync = new CountDownLatch(1);

        String categories = extras.getString(CatalogSyncConstants.SYNC_PARAM_GROUP_ID_LIST);

        try {
            String[] categoryList = null;

            if (StringUtils.isNotBlank(categories)) {
                categoryList = categories.split(CatalogSyncConstants.SYNC_PARAM_GROUP_ID_LIST_SEPARATOR);
            }

            syncCatalog(categoryList);

            // Save the date
            mContentServiceHelper.saveCatalogLastSyncDate(new Date().getTime());

            // Showing the notification
            showNotificationProgress(true);

            // Wait for the end of the sync
            mBlockSync.await(getContext().getResources().getInteger(R.integer.sync_timeout_in_min),
                    TimeUnit.MINUTES);

        } catch (InterruptedException e) {
            Log.e(TAG, "Error syncing the catalog");
        }
    }
}

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

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_collect_survey_data);

    buildCustomActionBar();//  w w  w. ja va2  s. co m

    if (savedInstanceState == null) {
        // create and attach our model fragment.
        getSupportFragmentManager().beginTransaction().add(new SurveyModelHolder(), "model").commit();
    } else {
        gpsTrackingOn = savedInstanceState.getBoolean(GPS_TRACKING_BUNDLE_KEY);
        gpsTimeoutCount = savedInstanceState.getInt(GPS_TIMEOUT_BUNDLE_KEY);
    }

    pagerAdapter = new SurveyPagerAdapter(getSupportFragmentManager());
    pager = (ValidatingViewPager) findViewById(R.id.surveyPager);
    leftArrow = findViewById(R.id.leftArrow);
    rightArrow = findViewById(R.id.rightArrow);
    Intent i = getIntent();
    int speciesId = i.getIntExtra(CollectSurveyData.SPECIES, 0);
    if (speciesId > 0) {
        SpeciesDAO speciesDao = new SpeciesDAO(this);
        selectedSpecies = speciesDao.load(Species.class, speciesId);
    }

}

From source file:com.facebook.widget.FacebookDialog.java

/**
 * Determines whether the native dialog completed normally (without error or exception).
 *
 * @param result the bundle passed back to onActivityResult
 * @return true if the native dialog completed normally
 *//* ww w . j  av  a  2  s. co  m*/
public static boolean getNativeDialogDidComplete(Bundle result) {
    if (result.containsKey(RESULT_ARGS_DIALOG_COMPLETE_KEY)) {
        return result.getBoolean(RESULT_ARGS_DIALOG_COMPLETE_KEY);
    }
    return result.getBoolean(EXTRA_DIALOG_COMPLETE_KEY, false);
}

From source file:com.uproot.trackme.LocationActivity.java

/**
 * This sample demonstrates how to incorporate location based services in your
 * app and process location updates. The app also shows how to convert
 * lat/long coordinates to human-readable addresses.
 */// ww w . j  a  v  a  2 s.  co  m
@SuppressLint({ "NewApi", "HandlerLeak" })
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // clearDB();
    initDatabase();

    Button btn1 = (Button) findViewById(R.id.btn1);
    btn1.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
        }
    });

    if (savedInstanceState != null) {
        mUseFine = savedInstanceState.getBoolean(KEY_FINE);
        mUseBoth = savedInstanceState.getBoolean(KEY_BOTH);
    } else {
        mUseFine = false;
        mUseBoth = false;
    }
    mUseFine = false;
    mUseBoth = true;
    mLatLng = (TextView) findViewById(R.id.latlng);
    mAddress = (TextView) findViewById(R.id.address);

    // The isPresent() helper method is only available on Gingerbread or
    // above.
    mGeocoderAvailable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && Geocoder.isPresent();

    // Handler for updating text fields on the UI like the lat/long and
    // address.
    mHandler = new Handler() {
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case UPDATE_ADDRESS:
                mAddress.setText((String) msg.obj);
                break;
            case UPDATE_LATLNG:
                mLatLng.setText((String) msg.obj);
                break;
            }
        }
    };
    // Get a reference to the LocationManager object.
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    setup();

    myTimer.scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            getLocs();
        }
    }, 0, setF * 1000);

}

From source file:se.leap.bitmaskclient.ProviderAPI.java

@Override
protected void onHandleIntent(Intent command) {
    final ResultReceiver receiver = command.getParcelableExtra(RECEIVER_KEY);
    String action = command.getAction();
    Bundle parameters = command.getBundleExtra(PARAMETERS);

    if (provider_api_url == null && preferences.contains(Provider.KEY)) {
        try {/*from  w w w . j av a 2  s  .co m*/
            JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, ""));
            provider_api_url = provider_json.getString(Provider.API_URL) + "/"
                    + provider_json.getString(Provider.API_VERSION);
            go_ahead = true;
        } catch (JSONException e) {
            go_ahead = false;
        }
    }

    if (action.equalsIgnoreCase(SET_UP_PROVIDER)) {
        Bundle result = setUpProvider(parameters);
        if (go_ahead) {
            if (result.getBoolean(RESULT_KEY)) {
                receiver.send(PROVIDER_OK, result);
            } else {
                receiver.send(PROVIDER_NOK, result);
            }
        }
    } else if (action.equalsIgnoreCase(SIGN_UP)) {
        UserStatus.updateStatus(UserStatus.SessionStatus.SIGNING_UP, resources);
        Bundle result = tryToRegister(parameters);
        if (result.getBoolean(RESULT_KEY)) {
            receiver.send(SUCCESSFUL_SIGNUP, result);
        } else {
            receiver.send(FAILED_SIGNUP, result);
        }
    } else if (action.equalsIgnoreCase(LOG_IN)) {
        UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_IN, resources);
        Bundle result = tryToAuthenticate(parameters);
        if (result.getBoolean(RESULT_KEY)) {
            receiver.send(SUCCESSFUL_LOGIN, result);
            UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_IN, resources);
        } else {
            receiver.send(FAILED_LOGIN, result);
            UserStatus.updateStatus(UserStatus.SessionStatus.NOT_LOGGED_IN, resources);
        }
    } else if (action.equalsIgnoreCase(LOG_OUT)) {
        UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_OUT, resources);
        if (logOut()) {
            receiver.send(SUCCESSFUL_LOGOUT, Bundle.EMPTY);
            UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_OUT, resources);
        } else {
            receiver.send(LOGOUT_FAILED, Bundle.EMPTY);
            UserStatus.updateStatus(UserStatus.SessionStatus.DIDNT_LOG_OUT, resources);
        }
    } else if (action.equalsIgnoreCase(DOWNLOAD_CERTIFICATE)) {
        if (updateVpnCertificate()) {
            receiver.send(CORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY);
        } else {
            receiver.send(INCORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY);
        }
    } else if (action.equalsIgnoreCase(DOWNLOAD_EIP_SERVICE)) {
        Bundle result = getAndSetEipServiceJson();
        if (result.getBoolean(RESULT_KEY)) {
            receiver.send(CORRECTLY_DOWNLOADED_EIP_SERVICE, result);
        } else {
            receiver.send(INCORRECTLY_DOWNLOADED_EIP_SERVICE, result);
        }
    }
}

From source file:in.rade.armud.armudclient.MainActivity.java

/**
 * Updates fields based on data stored in the bundle.
 *
 * @param savedInstanceState The activity state saved in the Bundle.
 *///from   ww  w. ja  v a2s  .  co m
private void updateValuesFromBundle(Bundle savedInstanceState) {
    Log.i(LOCATION_TAG, "Updating values from bundle");
    if (savedInstanceState != null) {
        // Update the value of mRequestingLocationUpdates from the Bundle, and make sure that
        // the Start Updates and Stop Updates buttons are correctly enabled or disabled.
        if (savedInstanceState.keySet().contains(REQUESTING_LOCATION_UPDATES_KEY)) {
            mRequestingLocationUpdates = savedInstanceState.getBoolean(REQUESTING_LOCATION_UPDATES_KEY);
        }

        // Update the value of mCurrentLocation from the Bundle and update the UI to show the
        // correct latitude and longitude.
        if (savedInstanceState.keySet().contains(LOCATION_KEY)) {
            // Since LOCATION_KEY was found in the Bundle, we can be sure that mCurrentLocation
            // is not null.
            mCurrentLocation = savedInstanceState.getParcelable(LOCATION_KEY);
        }

        // Update the value of mLastUpdateTime from the Bundle and update the UI.
        if (savedInstanceState.keySet().contains(LAST_UPDATED_TIME_STRING_KEY)) {
            mLastUpdateTime = savedInstanceState.getString(LAST_UPDATED_TIME_STRING_KEY);
        }
        updateUI();
    }
}

From source file:com.radicaldynamic.groupinform.activities.AccountFolderList.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.generic_list);

    if (savedInstanceState == null) {
        Intent intent = getIntent();//from  ww w. j a v a2  s  .c  o  m

        if (intent == null) {
            // Load defaults
        } else {
            mCopyToFolder = intent.getBooleanExtra(KEY_COPY_TO_FOLDER, false);
        }
    } else {
        if (savedInstanceState.containsKey(KEY_COPY_TO_FOLDER))
            mCopyToFolder = savedInstanceState.getBoolean(KEY_COPY_TO_FOLDER);

        if (savedInstanceState.containsKey(KEY_FOLDER_ID))
            mSelectedFolderId = savedInstanceState.getString(KEY_FOLDER_ID);

        if (savedInstanceState.containsKey(KEY_FOLDER_NAME))
            mSelectedFolderName = savedInstanceState.getString(KEY_FOLDER_NAME);

        Object data = getLastNonConfigurationInstance();

        if (data instanceof RefreshViewTask)
            mRefreshViewTask = (RefreshViewTask) data;
        else if (data instanceof SynchronizeFoldersTask)
            mSynchronizeFoldersTask = (SynchronizeFoldersTask) data;
    }

    if (mCopyToFolder)
        setTitle(getString(R.string.app_name) + " > " + getString(R.string.tf_copy_to_folder));
    else
        setTitle(getString(R.string.app_name) + " > " + getString(R.string.tf_form_folders));
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setVolumeControlStream(AudioManager.STREAM_ALARM);

    mFactory = LayoutInflater.from(this);
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mSortType = mPrefs.getInt(PREF_SORT, SORT_BY_NAME);
    mSelectedCitiesHeaderString = getString(R.string.selected_cities_label);
    if (savedInstanceState != null) {
        mQueryTextBuffer.append(savedInstanceState.getString(KEY_SEARCH_QUERY));
        mSearchMode = savedInstanceState.getBoolean(KEY_SEARCH_MODE);
        mPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
    }/*from   www.  j  a  v a2  s.  c om*/
    updateLayout();
}

From source file:chaitanya.im.searchforreddit.LauncherActivity.java

public void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    Log.d(TAG, "onRestoreInstanceState");
    sortButtonLabel = savedInstanceState.getString(SORT_BUTTON_LABEL);
    timeButtonLabel = savedInstanceState.getString(TIME_BUTTON_LABEL);
    timeValue = savedInstanceState.getString(TIME_VALUE);
    sortValue = savedInstanceState.getString(SORT_VALUE);
    searchOptionsFlag = savedInstanceState.getBoolean(SEARCH_OPTIONS_FLAG);
    clearSearchBoxButtonFlag = savedInstanceState.getBoolean(CLEAR_SEARCH_BOX_BUTTON_FLAG);

    if (searchOptionsFlag) {
        searchOptions.setVisibility(View.VISIBLE);
    }/*from  w w  w .ja  v  a2s . co m*/
    if (clearSearchBoxButtonFlag) {
        clearSearchBoxButton.setVisibility(View.VISIBLE);
    }
    timeButton.setText(timeButtonLabel);
    sortButton.setText(sortButtonLabel);
}

From source file:no.nordicsemi.android.nrftoolbox.dfu.DfuActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_feature_dfu);
    isBLESupported();/*from w w  w  . j a v  a2 s  . co m*/
    setGUI();

    // restore saved state
    if (savedInstanceState != null) {
        mFilePath = savedInstanceState.getString(DATA_FILE_PATH);
        mFileStreamUri = savedInstanceState.getParcelable(DATA_FILE_STREAM);
        mStatusOk = savedInstanceState.getBoolean(DATA_STATUS);
        mUploadButton.setEnabled(mStatusOk);
    }
    mSelectedDevice = getIntent().getParcelableExtra(ModuleActivity.EXTRA_BLE_DEVICE);
}