List of usage examples for android.os Bundle containsKey
public boolean containsKey(String key)
From source file:com.eleybourn.bookcatalogue.utils.Utils.java
/** * Add the current text data to the collection if not present, otherwise * append the data as a list./*from www . j a v a 2 s .co m*/ * * @param key Key for data to add */ static public void appendOrAdd(Bundle values, String key, String value) { String s = Utils.encodeListItem(value, '|'); if (!values.containsKey(key) || values.getString(key).length() == 0) { values.putString(key, s); } else { String curr = values.getString(key); values.putString(key, curr + "|" + s); } }
From source file:com.mk.a2dp.billingUtil.IabHelper.java
int queryPurchases(Inventory inv) throws JSONException, RemoteException { // Query purchases logDebug("Querying owned items..."); logDebug("Package name: " + mContext.getPackageName()); // boolean hasMore = true; boolean verificationFailed = false; String continueToken = null;/*from w w w . j a va 2s .co m*/ do { logDebug("Calling getPurchases with continuation token: " + continueToken); Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), ITEM_TYPE_INAPP, continueToken); int response = getResponseCodeFromBundle(ownedItems); logDebug("Owned items response: " + String.valueOf(response)); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getPurchases() failed: " + getResponseDesc(response)); return response; } if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) { logError("Bundle returned from getPurchases() doesn't contain required fields."); return IABHELPER_BAD_RESPONSE; } ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); String sku = ownedSkus.get(i); if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) { logDebug("Sku is owned: " + sku); Purchase purchase = new Purchase(purchaseData, signature); if (TextUtils.isEmpty(purchase.getToken())) { logWarn("BUG: empty/null token!"); logDebug("Purchase data: " + purchaseData); } // Record ownership and token inv.addPurchase(purchase); } else { logWarn("Purchase signature verification **FAILED**. Not adding item."); logDebug(" Purchase data: " + purchaseData); logDebug(" Signature: " + signature); verificationFailed = true; } } continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); logDebug("Continuation token: " + continueToken); } while (!TextUtils.isEmpty(continueToken)); return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK; }
From source file:com.ryan.ryanreader.activities.PostSubmitActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { PrefsUtility.applyTheme(this); super.onCreate(savedInstanceState); final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.post_submit); typeSpinner = (Spinner) layout.findViewById(R.id.post_submit_type); usernameSpinner = (Spinner) layout.findViewById(R.id.post_submit_username); subredditEdit = (EditText) layout.findViewById(R.id.post_submit_subreddit); titleEdit = (EditText) layout.findViewById(R.id.post_submit_title); textEdit = (EditText) layout.findViewById(R.id.post_submit_body); if (getIntent() != null && getIntent().hasExtra("subreddit")) { final String subreddit = getIntent().getStringExtra("subreddit"); if (subreddit != null && subreddit.length() > 0 && !subreddit.equals("all") && subreddit.matches("\\w+")) { subredditEdit.setText(subreddit); }/*from w ww .j av a 2 s. c om*/ } else if (savedInstanceState != null && savedInstanceState.containsKey("post_title")) { titleEdit.setText(savedInstanceState.getString("post_title")); textEdit.setText(savedInstanceState.getString("post_body")); subredditEdit.setText(savedInstanceState.getString("subreddit")); typeSpinner.setSelection(savedInstanceState.getInt("post_type")); } final ArrayList<RedditAccount> accounts = RedditAccountManager.getInstance(this).getAccounts(); final ArrayList<String> usernames = new ArrayList<String>(); for (RedditAccount account : accounts) { if (!account.isAnonymous()) { usernames.add(account.username); } } if (usernames.size() == 0) { General.quickToast(this, R.string.error_toast_notloggedin); finish(); } usernameSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usernames)); typeSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, postTypes)); // TODO remove the duplicate code here if (typeSpinner.getSelectedItem().equals("Link")) { textEdit.setHint("URL"); // TODO string textEdit.setInputType(android.text.InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); textEdit.setSingleLine(true); } else { textEdit.setHint("Self Text"); // TODO string textEdit.setInputType(android.text.InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE | InputType.TYPE_TEXT_FLAG_MULTI_LINE); textEdit.setSingleLine(false); } typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (typeSpinner.getSelectedItem().equals("Link")) { textEdit.setHint("URL"); // TODO string textEdit.setInputType( android.text.InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); textEdit.setSingleLine(true); } else { textEdit.setHint("Self Text"); // TODO string textEdit.setInputType(android.text.InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE | InputType.TYPE_TEXT_FLAG_MULTI_LINE); textEdit.setSingleLine(false); } } public void onNothingSelected(AdapterView<?> parent) { } }); final ScrollView sv = new ScrollView(this); sv.addView(layout); setContentView(sv); }
From source file:com.markupartist.sthlmtraveling.RoutesActivity.java
/** * Restores the search routes task./*from w w w . ja va 2 s. co m*/ * @param savedInstanceState the saved state */ private void restoreJourneyQuery(Bundle savedInstanceState) { if (savedInstanceState.containsKey(EXTRA_JOURNEY_QUERY)) { mJourneyQuery = savedInstanceState.getParcelable(EXTRA_JOURNEY_QUERY); } }
From source file:es.upv.riromu.arbre.main.MainActivity.java
@Override protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); if (savedInstanceState.containsKey("cropping")) { state[CROP_IMAGE] = savedInstanceState.getBoolean("cropping"); }// w w w . ja v a2s . c o m if (savedInstanceState.containsKey("treated")) { state[TREAT_IMAGE] = savedInstanceState.getBoolean("treated"); } if (savedInstanceState.containsKey("image_uri")) { image_uri = Uri.parse(savedInstanceState.getString("image_uri")); } if (savedInstanceState.getBoolean("image")) { String fileName = "temp_image.jpg"; String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath() + "/" + fileName; File file = new File(fileURL); try { InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file)); image = Util.decodeScaledBitmapFromFile(file.getPath(), MAX_SIZE, MAX_SIZE); // image = BitmapFactory.decodeStream(imageStream); } catch (FileNotFoundException e) { Log.e(TAG, e.getMessage()); } } if (state[CROP_IMAGE]) { String fileName = "temp_cropped.jpg"; String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath() + "/" + fileName; File file = new File(fileURL); try { InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file)); croppedimage = BitmapFactory.decodeStream(imageStream); imageStream.close(); } catch (FileNotFoundException e) { Log.e(TAG, e.getMessage()); } catch (IOException e) { Log.e(TAG, e.getMessage()); } } if (state[TREAT_IMAGE]) { String fileName = "temp_treated.jpg"; String fileURL = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath() + "/" + fileName; File file = new File(fileURL); try { InputStream imageStream = getContentResolver().openInputStream(Uri.fromFile(file)); ImageView imv = (ImageView) findViewById(R.id.image_intro); imv.setImageBitmap(BitmapFactory.decodeStream(imageStream)); imageStream.close(); } catch (FileNotFoundException e) { Log.e(TAG, e.getMessage()); } catch (IOException e) { Log.e(TAG, e.getMessage()); } } ImageView imv = (ImageView) findViewById(R.id.image_intro); colours = savedInstanceState.getIntArray("colours"); if ((!state[TREAT_IMAGE]) && state[CROP_IMAGE]) imv.setImageBitmap(croppedimage); else { imv.setImageBitmap(image); } TextView imc = (TextView) findViewById(R.id.textView); imc.setBackgroundColor(Color.rgb(colours[COLOUR_R], colours[COLOUR_G], colours[COLOUR_B])); }
From source file:com.freshplanet.inapppurchase.IabHelper.java
int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException { // Query purchases logDebug("Querying owned items, item type: " + itemType); logDebug("Package name: " + mContext.getPackageName()); boolean verificationFailed = false; String continueToken = null;/* w w w. ja v a 2s . c o m*/ do { logDebug("Calling getPurchases with continuation token: " + continueToken); Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken); int response = getResponseCodeFromBundle(ownedItems); logDebug("Owned items response: " + String.valueOf(response)); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getPurchases() failed: " + getResponseDesc(response)); return response; } if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) { logError("Bundle returned from getPurchases() doesn't contain required fields."); return IABHELPER_BAD_RESPONSE; } ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); String sku = ownedSkus.get(i); logDebug("Sku is owned: " + sku); Purchase purchase = new Purchase(itemType, purchaseData, signature); if (TextUtils.isEmpty(purchase.getToken())) { logWarn("BUG: empty/null token!"); logDebug("Purchase data: " + purchaseData); } // Record ownership and token inv.addPurchase(purchase); } continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); logDebug("Continuation token: " + continueToken); } while (!TextUtils.isEmpty(continueToken)); return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK; }
From source file:ch.fixme.status.Main.java
private void showHsInfo(Intent intent, Bundle savedInstanceState) { // Get hackerspace api url if (intent != null && intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID)) { mApiUrl = mPrefs.getString(PREF_API_URL_WIDGET + intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID), ParseGeneric.API_DEFAULT); } else if (intent != null && intent.hasExtra(STATE_HS)) { mApiUrl = intent.getStringExtra(STATE_HS); } else {/*from w w w.j a va 2 s. c o m*/ mApiUrl = mPrefs.getString(PREF_API_URL, ParseGeneric.API_DEFAULT); } // Get Data final Bundle data = (Bundle) getLastNonConfigurationInstance(); if (data == null || (savedInstanceState == null && !savedInstanceState.containsKey(STATE_HS))) { getApiTask = new GetApiTask(); getApiTask.execute(mApiUrl); } else { finishApi = true; mResultHs = data.getString(STATE_HS); populateDataHs(); } // Update widget Widget.UpdateAllWidgets(getApplicationContext()); }
From source file:com.pgmacdesign.vending.billing.util.IabHelper.java
int queryPurchases(Inventory inv) throws JSONException, RemoteException { // Query purchases logDebug("Querying owned items..."); logDebug("Package name: " + mContext.getPackageName()); boolean verificationFailed = false; String continueToken = null;// ww w . j ava2 s . c om do { logDebug("Calling getPurchases with continuation token: " + continueToken); Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), ITEM_TYPE_INAPP, continueToken); int response = getResponseCodeFromBundle(ownedItems); logDebug("Owned items response: " + String.valueOf(response)); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getPurchases() failed: " + getResponseDesc(response)); return response; } if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) { logError("Bundle returned from getPurchases() doesn't contain required fields."); return IABHELPER_BAD_RESPONSE; } ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); String sku = ownedSkus.get(i); if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) { logDebug("Sku is owned: " + sku); Purchase purchase = new Purchase(purchaseData, signature); if (TextUtils.isEmpty(purchase.getToken())) { logWarn("BUG: empty/null token!"); logDebug("Purchase data: " + purchaseData); } // Record ownership and token inv.addPurchase(purchase); } else { logWarn("Purchase signature verification **FAILED**. Not adding item."); logDebug(" Purchase data: " + purchaseData); logDebug(" Signature: " + signature); verificationFailed = true; } } continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); logDebug("Continuation token: " + continueToken); } while (!TextUtils.isEmpty(continueToken)); return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK; }
From source file:br.com.cpb.esperanca.iab.IabHelper.java
int queryPurchases(Inventory inv) throws JSONException, RemoteException { // Query purchases logDebug("Querying owned items..."); logDebug("Package name: " + mContext.getPackageName()); boolean verificationFailed = false; String continueToken = null;/*www. j a va2 s .c om*/ do { logDebug("Calling getPurchases with continuation token: " + continueToken); if (mService == null) return IABHELPER_VERIFICATION_FAILED; Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), ITEM_TYPE_INAPP, continueToken); int response = getResponseCodeFromBundle(ownedItems); logDebug("Owned items response: " + String.valueOf(response)); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getPurchases() failed: " + getResponseDesc(response)); return response; } if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) { logError("Bundle returned from getPurchases() doesn't contain required fields."); return IABHELPER_BAD_RESPONSE; } ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); String sku = ownedSkus.get(i); if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) { logDebug("Sku is owned: " + sku); Purchase purchase = new Purchase(purchaseData, signature); if (TextUtils.isEmpty(purchase.getToken())) { logWarn("BUG: empty/null token!"); logDebug("Purchase data: " + purchaseData); } // Record ownership and token inv.addPurchase(purchase); } else { logWarn("Purchase signature verification **FAILED**. Not adding item."); logDebug(" Purchase data: " + purchaseData); logDebug(" Signature: " + signature); verificationFailed = true; } } continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); logDebug("Continuation token: " + continueToken); } while (!TextUtils.isEmpty(continueToken)); return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK; }
From source file:me.ccrama.redditslide.util.IabHelper.java
private int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException { // Query purchases logDebug("Querying owned items, item type: " + itemType); logDebug("Package name: " + mContext.getPackageName()); boolean verificationFailed = false; String continueToken = null;/*from www . j av a 2 s . com*/ do { logDebug("Calling getPurchases with continuation token: " + continueToken); Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken); int response = getResponseCodeFromBundle(ownedItems); logDebug("Owned items response: " + String.valueOf(response)); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getPurchases() failed: " + getResponseDesc(response)); return response; } if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) { logError("Bundle returned from getPurchases() doesn't contain required fields."); return IABHELPER_BAD_RESPONSE; } List<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST); List<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); List<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); String sku = ownedSkus.get(i); if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) { logDebug("Sku is owned: " + sku); Purchase purchase = new Purchase(itemType, purchaseData, signature); if (TextUtils.isEmpty(purchase.getToken())) { logWarn("BUG: empty/null token!"); logDebug("Purchase data: " + purchaseData); } // Record ownership and token inv.addPurchase(purchase); } else { logWarn("Purchase signature verification **FAILED**. Not adding item."); logDebug(" Purchase data: " + purchaseData); logDebug(" Signature: " + signature); verificationFailed = true; } } continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); logDebug("Continuation token: " + continueToken); } while (!TextUtils.isEmpty(continueToken)); return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK; }