List of usage examples for android.os Bundle containsKey
public boolean containsKey(String key)
From source file:no.nordicsemi.android.nrftoolbox.dfu.DfuActivity.java
@Override protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { if (resultCode != RESULT_OK) return;//from ww w.j a v a2s . c o m switch (requestCode) { case SELECT_FILE_REQ: // clear previous data mFilePath = null; mFileStreamUri = null; // and read new one final Uri uri = data.getData(); /* * The URI returned from application may be in 'file' or 'content' schema. * 'File' schema allows us to create a File object and read details from if directly. * * Data from 'Content' schema must be read by Content Provider. To do that we are using a Loader. */ if (uri.getScheme().equals("file")) { // the direct path to the file has been returned final String path = uri.getPath(); final File file = new File(path); mFilePath = path; mFileNameView.setText(file.getName()); mFileSizeView.setText(getString(R.string.dfu_file_size_text, file.length())); final boolean isHexFile = mStatusOk = MimeTypeMap.getFileExtensionFromUrl(path) .equalsIgnoreCase("HEX"); mFileStatusView.setText(isHexFile ? R.string.dfu_file_status_ok : R.string.dfu_file_status_invalid); mUploadButton.setEnabled(mSelectedDevice != null && isHexFile); } else if (uri.getScheme().equals("content")) { // an Uri has been returned mFileStreamUri = uri; // if application returned Uri for streaming, let's us it. Does it works? // FIXME both Uris works with Google Drive app. Why both? What's the difference? How about other apps like DropBox? final Bundle extras = data.getExtras(); if (extras != null && extras.containsKey(Intent.EXTRA_STREAM)) mFileStreamUri = extras.getParcelable(Intent.EXTRA_STREAM); // file name and size must be obtained from Content Provider final Bundle bundle = new Bundle(); bundle.putParcelable(EXTRA_URI, uri); getSupportLoaderManager().restartLoader(0, bundle, this); } break; default: break; } }
From source file:com.starwood.anglerslong.LicenseAddActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle bundle = this.getIntent().getExtras(); setContentView(R.layout.license_add); Spinner s = (Spinner) findViewById(R.id.spinner); @SuppressWarnings("unchecked") ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.state_array)); s.setAdapter(adapter);//from w w w . ja v a 2s. c o m s.setOnItemSelectedListener(this); isPopulated = bundle.getBoolean("isPopulated"); isArrayEmpty = bundle.getBoolean("isArrayEmpty"); if (bundle.containsKey("isEdit")) isEdit = bundle.getBoolean("isEdit"); if (bundle.containsKey("currentItemID")) currentItemID = bundle.getInt("currentItemID"); getSupportActionBar().setTitle(bundle.getString("title")); // getSupportActionBar().setSubtitle(bundle.getString("subtitle")); if (isEdit) { try { JsonStorage jsonStorage = new JsonStorage(getApplicationContext()); String json = jsonStorage.readProfileJSON(); // Store the JSON into string JSONObject j = new JSONObject(json); JSONObject outer = j.getJSONObject("outermost"); // Outermost JSON JSONArray innerArray = outer.getJSONArray("license"); JSONObject inner = innerArray.getJSONObject(currentItemID); Spinner editSpinner = (Spinner) findViewById(R.id.spinner); editSpinner.setSelection(inner.getInt("state") + 1); // Set spinner EditText edit = (EditText) findViewById(R.id.license_name); edit.setText(inner.getString("name")); edit = (EditText) findViewById(R.id.license_number); edit.setText(inner.getString("number")); edit = (EditText) findViewById(R.id.license_type); edit.setText(inner.getString("type")); edit = (EditText) findViewById(R.id.license_issue_date); edit.setText(inner.getString("issue_date")); edit = (EditText) findViewById(R.id.license_expiration_date); edit.setText(inner.getString("exp_date")); edit = (EditText) findViewById(R.id.license_birthday); edit.setText(inner.getString("birthday")); edit = (EditText) findViewById(R.id.license_huntered); edit.setText(inner.getString("huntered")); } catch (JSONException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:com.soomla.store.billing.nokia.NokiaIabHelper.java
/** * Queries a chunk of SKU details to prevent Google's 20 items bug. * * @throws RemoteException// w w w . j ava2 s . c om * @throws JSONException */ private int querySkuDetailsChunk(String itemType, IabInventory inv, ArrayList<String> chunkSkuList) throws RemoteException, JSONException { Bundle querySkus = new Bundle(); querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, chunkSkuList); Bundle skuDetails = mService.getProductDetails(3, SoomlaApp.getAppContext().getPackageName(), itemType, querySkus); if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) { int response = getResponseCodeFromBundle(skuDetails); if (response != IabResult.BILLING_RESPONSE_RESULT_OK) { SoomlaUtils.LogDebug(TAG, "querySkuDetailsChunk() failed: " + IabResult.getResponseDesc(response)); return response; } else { SoomlaUtils.LogError(TAG, "querySkuDetailsChunk() returned a bundle with neither an error nor a detail list."); return IabResult.IABHELPER_BAD_RESPONSE; } } ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST); for (String thisResponse : responseList) { IabSkuDetails d = new IabSkuDetails(itemType, thisResponse); SoomlaUtils.LogDebug(TAG, "Got sku details: " + d); inv.addSkuDetails(d); } return IabResult.BILLING_RESPONSE_RESULT_OK; }
From source file:com.ginstr.android.service.opencellid.upload.data.MeasurementsUploaderService.java
/** * checks intent configuration parameters * @param extras/*from ww w .j a v a 2s . co m*/ */ private void getExtraParameters(Bundle extras) { if (extras != null) { writeToLog("configurationReceiver.onReceive() extras : " + extras.keySet()); if (extras != null) { appId = extras.getString(UploadConstants.PREF_APPID_KEY); if (extras.containsKey(UploadConstants.PREF_API_KEY)) apiKey = extras.getString(UploadConstants.PREF_API_KEY); if (extras.containsKey(UploadConstants.PREF_OPENCELL_UPLOAD_URL_KEY)) openCellUrl = extras.getString(UploadConstants.PREF_OPENCELL_UPLOAD_URL_KEY); if (extras.containsKey(UploadConstants.PREF_OPENCELL_NETWORK_UPLOAD_URL_KEY)) networksUrl = extras.getString(UploadConstants.PREF_OPENCELL_NETWORK_UPLOAD_URL_KEY); testEnvironment = extras.getBoolean(UploadConstants.PREF_TEST_ENVIRONMENT_KEY, UploadConstants.PREF_TEST_ENVIRONMENT); if (openCellUrl == null) { if (testEnvironment) { openCellUrl = UploadConstants.OPEN_CELL_TEST_UPLOAD_URL; } else { openCellUrl = UploadConstants.OPEN_CELL_DEFAULT_UPLOAD_URL; } } if (networksUrl == null) { if (testEnvironment) { networksUrl = UploadConstants.OPENCELL_NETWORKS_TEST_UPLOAD_URL; } else { networksUrl = UploadConstants.OPENCELL_NETWORKS_UPLOAD_URL; } } if (extras.containsKey(UploadConstants.PREF_NEW_DATA_CHECK_INTERVAL_KEY)) newDataCheckInterval = extras.getLong(UploadConstants.PREF_NEW_DATA_CHECK_INTERVAL_KEY); if (newDataCheckInterval < UploadConstants.NEW_DATA_CHECK_INTERVAL_LONG_DEFAULT) newDataCheckInterval = UploadConstants.NEW_DATA_CHECK_INTERVAL_LONG_DEFAULT; if (extras.containsKey(UploadConstants.PREF_ONLY_WIFI_UPLOAD_KEY)) wifiOnly = extras.getBoolean(UploadConstants.PREF_ONLY_WIFI_UPLOAD_KEY); // check if the maxLogFileSize parameter is provided through intent if (extras.containsKey(UploadConstants.PREFKEY_MAX_LOG_SIZE_INT)) { maxLogFileSize = extras.getInt(UploadConstants.PREFKEY_MAX_LOG_SIZE_INT); mLibContext.getLogService().setMaxLogFileSize(maxLogFileSize); } // check if the logToFileEnabled parameter is provided through intent if (extras.containsKey(UploadConstants.PREFKEY_LOG_TO_FILE)) { logToFileEnabled = extras.getBoolean(UploadConstants.PREFKEY_LOG_TO_FILE); mLibContext.getLogService().setFileLoggingEnabled(logToFileEnabled); } } writeToLog("onConfigurationReceiver ()"); writeToLog("apiKey = " + apiKey); writeToLog("openCellUrl = " + openCellUrl); writeToLog("networks url = " + networksUrl); writeToLog("newDataCheckInterval = " + newDataCheckInterval); writeToLog("wifiOnly = " + wifiOnly); writeToLog("testEnvironment = " + testEnvironment); } }
From source file:org.dvbviewer.controller.ui.fragments.ChannelEpg.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setLayoutRessource(R.layout.fragment_channel_epg); mImageCacher = new ImageCacher(getActivity()); if (savedInstanceState != null && savedInstanceState.containsKey(Channel.class.getName())) { mCHannel = savedInstanceState.getParcelable(Channel.class.getName()); }// ww w . j ava 2 s .c o m }
From source file:com.mirasense.scanditsdk.plugin.ScanditSDKActivity.java
@SuppressWarnings("deprecation") public void initializeAndStartBarcodeRecognition(Bundle extras) { // Switch to full screen. getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); requestWindowFeature(Window.FEATURE_NO_TITLE); ScanSettings settings = ScanditSDKParameterParser.settingsForBundle(extras); mBarcodePicker = new SearchBarBarcodePicker(this, settings); this.setContentView(mBarcodePicker); Display display = getWindowManager().getDefaultDisplay(); ScanditSDKParameterParser.updatePickerUIFromBundle(mBarcodePicker, extras, display.getWidth(), display.getHeight());//from ww w . ja v a 2 s. c o m if (extras.containsKey(ScanditSDKParameterParser.paramContinuousMode)) { mContinuousMode = extras.getBoolean(ScanditSDKParameterParser.paramContinuousMode); } // Register listener, in order to be notified about relevant events // (e.g. a successfully scanned bar code). mBarcodePicker.setOnScanListener(this); mBarcodePicker.setOnSearchBarListener(this); if (extras.containsKey(ScanditSDKParameterParser.paramPaused) && extras.getBoolean(ScanditSDKParameterParser.paramPaused)) { mStartPaused = true; } else { mStartPaused = false; } }
From source file:com.soomla.store.billing.google.GoogleIabHelper.java
/** * Queries a chunk of SKU details to prevent Google's 20 items bug. * * @throws RemoteException/*w w w . j a va 2 s. c o m*/ * @throws JSONException */ private int querySkuDetailsChunk(String itemType, IabInventory inv, ArrayList<String> chunkSkuList) throws RemoteException, JSONException { Bundle querySkus = new Bundle(); querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, chunkSkuList); Bundle skuDetails = mService.getSkuDetails(3, SoomlaApp.getAppContext().getPackageName(), itemType, querySkus); if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) { int response = getResponseCodeFromBundle(skuDetails); if (response != IabResult.BILLING_RESPONSE_RESULT_OK) { SoomlaUtils.LogDebug(TAG, "querySkuDetailsChunk() failed: " + IabResult.getResponseDesc(response)); return response; } else { SoomlaUtils.LogError(TAG, "querySkuDetailsChunk() returned a bundle with neither an error nor a detail list."); return IabResult.IABHELPER_BAD_RESPONSE; } } ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST); for (String thisResponse : responseList) { IabSkuDetails d = new IabSkuDetails(itemType, thisResponse); SoomlaUtils.LogDebug(TAG, "Got sku details: " + d); inv.addSkuDetails(d); } return IabResult.BILLING_RESPONSE_RESULT_OK; }
From source file:com.irccloud.android.fragment.EditConnectionFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Context ctx = getActivity();//w ww .j a va 2s . co m if (ctx == null) return null; LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.dialog_edit_connection, null); init(v); if (savedInstanceState != null && savedInstanceState.containsKey("cid")) server = ServersDataSource.getInstance().getServer(savedInstanceState.getInt("cid")); final AlertDialog d = new AlertDialog.Builder(ctx) .setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) .setTitle((server == null) ? "Add A Network" : "Edit Connection").setView(v) .setPositiveButton((server == null) ? "Add" : "Save", null) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { NetworkConnection.getInstance().removeHandler(EditConnectionFragment.this); } }).create(); d.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { Button b = d.getButton(AlertDialog.BUTTON_POSITIVE); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { NetworkConnection.getInstance().removeHandler(EditConnectionFragment.this); NetworkConnection.getInstance().addHandler(EditConnectionFragment.this); reqid = save(); } }); } }); d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); return d; }
From source file:me.piebridge.prevent.framework.SystemReceiver.java
private void handleConfiguration(Bundle bundle) { setForceStopTimeout(bundle.getLong(PreventIntent.KEY_FORCE_STOP_TIMEOUT)); SystemHook.setDestroyProcesses(bundle.getBoolean(PreventIntent.KEY_DESTROY_PROCESSES)); SystemHook.setLockSyncSettings(bundle.getBoolean(PreventIntent.KEY_LOCK_SYNC_SETTINGS)); SystemHook.setUseAppStandby(bundle.getBoolean(PreventIntent.KEY_USE_APP_STANDBY)); setAutoPrevent(bundle.getBoolean(PreventIntent.KEY_AUTO_PREVENT, true)); if (bundle.containsKey(PreventIntent.KEY_STOP_SIGNATURE_APPS)) { // this is not an option can set from ui SystemHook.setStopSignatureApps(bundle.getBoolean(PreventIntent.KEY_STOP_SIGNATURE_APPS, true)); }/*from w w w .j a va2 s. co m*/ if (bundle.containsKey(PreventIntent.KEY_PREVENT_LIST)) { updatePreventList(bundle.getStringArrayList(PreventIntent.KEY_PREVENT_LIST)); } saveConfiguration(new Configuration(bundle), true); }