List of usage examples for android.os Bundle getInt
public int getInt(String key)
From source file:Main.java
public static int[] fillIntsFromKey(Bundle bundle, String baseKey) { int count = countIndexes(bundle, baseKey); int[] array = new int[count]; for (int i = 0; i < array.length; i++) array[i] = bundle.getInt(baseKey + i); return array; }
From source file:com.fanfou.app.opensource.update.AppVersionInfo.java
public static AppVersionInfo parseBundle(final Bundle bundle) { final AppVersionInfo info = new AppVersionInfo(); info.versionCode = bundle.getInt("versionCode"); info.versionName = bundle.getString("versionName"); info.releaseDate = bundle.getString("releaseDate"); info.changelog = bundle.getString("changelog"); info.downloadUrl = bundle.getString("downloadUrl"); info.versionType = bundle.getString("versionType"); info.packageName = bundle.getString("packageName"); info.forceUpdate = bundle.getBoolean("forceUpdate"); if (info.versionCode > 0) { return info; } else {//from w w w.j a v a2 s . c om return null; } }
From source file:Main.java
public static String toString(Intent intent) { StringBuilder sb = new StringBuilder(); sb.append(intent.getAction()).append(" "); Bundle bundle = intent.getExtras(); if (bundle != null) { Set<String> sets = bundle.keySet(); for (String key : sets) { if (bundle.get(key) instanceof Integer) { sb.append(key).append(":").append(bundle.getInt(key)).append("\n"); } else if (bundle.get(key) instanceof ArrayList) { sb.append(key).append(":").append(Arrays.toString(bundle.getIntegerArrayList(key).toArray())) .append("\n"); } else if (bundle.get(key) instanceof Parcelable) { sb.append(key).append(":").append(bundle.getParcelable(key).toString()).append("\n"); } else { sb.append(key).append(":").append(bundle.getString(key)).append("\n"); }/* ww w. ja v a 2s . c o m*/ } } return sb.toString(); }
From source file:com.battlelancer.seriesguide.api.Action.java
/** * Deserializes a {@link Bundle} into a {@link Action} object. *//*from ww w . j av a 2 s.c om*/ public static Action fromBundle(Bundle bundle) { String title = bundle.getString(KEY_TITLE); if (TextUtils.isEmpty(title)) { return null; } int entityIdentifier = bundle.getInt(KEY_ENTITY_IDENTIFIER); if (entityIdentifier <= 0) { return null; } Builder builder = new Builder(title, entityIdentifier); try { String viewIntent = bundle.getString(KEY_VIEW_INTENT); if (!TextUtils.isEmpty(viewIntent)) { builder.viewIntent(Intent.parseUri(viewIntent, Intent.URI_INTENT_SCHEME)); } } catch (URISyntaxException ignored) { } return builder.build(); }
From source file:org.linkdroid.PostJob.java
private static String obtainNonce(Bundle webhook) { String nonce = null;//from ww w . j a v a 2 s . co m if (shouldDoHmac(webhook)) { Integer nonceRandom = webhook.getInt(WebhookColumns.NONCE_RANDOM); if (nonceRandom != null && nonceRandom > 0) { nonce = Double.toString(Math.random()); } Integer nonceTimestamp = webhook.getInt(WebhookColumns.NONCE_TIMESTAMP); if (nonceTimestamp != null && nonceTimestamp > 0) { if (nonce != null) { nonce += " " + Long.toString(System.currentTimeMillis()); } else { nonce = Long.toString(System.currentTimeMillis()); } } Log.d(TAG, "NONCE " + nonce); } return nonce; }
From source file:net.gcompris.GComprisActivity.java
public static void checkPayment() { if (m_instance.m_service == null) { Log.e(QtApplication.QtTAG, "Check full version is bought failed: No billing service"); return;/* w ww.j a v a2 s. c o m*/ } try { Bundle ownedItems = m_instance.m_service.getPurchases(3, m_instance.getPackageName(), "inapp", null); int responseCode = ownedItems.getInt("RESPONSE_CODE"); if (responseCode == 0) { ArrayList ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST"); ArrayList purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST"); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = (String) purchaseDataList.get(i); String sku = (String) ownedSkus.get(i); if (sku.equals(SKU_NAME)) { bought(true); return; } else { Log.e(QtApplication.QtTAG, "Unknown item bought " + sku); } } bought(false); return; } else { bought(false); Log.e(QtApplication.QtTAG, "Item not owed " + responseCode); } } catch (Exception e) { Log.e(QtApplication.QtTAG, "Exception caught when checking if full version is bought!", e); } }
From source file:com.geekandroid.sdk.sample.JPushReceiver.java
private static String printBundle(Bundle bundle) { StringBuilder sb = new StringBuilder(); for (String key : bundle.keySet()) { if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) { sb.append("\nkey:" + key + ", value:" + bundle.getInt(key)); } else if (key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) { sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key)); } else if (key.equals(JPushInterface.EXTRA_EXTRA)) { if (bundle.getString(JPushInterface.EXTRA_EXTRA).isEmpty()) { Log.i(TAG, "This message has no Extra data"); continue; }// ww w. j a v a 2 s. co m try { JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA)); Iterator<String> it = json.keys(); while (it.hasNext()) { String myKey = it.next().toString(); sb.append("\nkey:" + key + ", value: [" + myKey + " - " + json.optString(myKey) + "]"); } } catch (JSONException e) { Log.e(TAG, "Get message extra JSON error!"); } } else { sb.append("\nkey:" + key + ", value:" + bundle.getString(key)); } } return sb.toString(); }
From source file:net.gcompris.GComprisActivity.java
public static void buyGCompris() { if (m_instance.m_service == null) { Log.e(QtApplication.QtTAG, "Buying full version failed: No billing service"); return;// ww w .j a v a 2 s . c o m } try { Bundle buyIntentBundle = m_instance.m_service.getBuyIntent(3, m_instance.getPackageName(), SKU_NAME, "inapp", ""); int responseCode = buyIntentBundle.getInt("RESPONSE_CODE"); if (responseCode == 0 /* BILLING_RESPONSE_RESULT_OK */) { PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); m_instance.startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); return; } else if (responseCode == 7 /* BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED */) { bought(true); } else { Log.e(QtApplication.QtTAG, "Buying full version failed: Response code == " + responseCode); } } catch (Exception e) { Log.e(QtApplication.QtTAG, "Exception caught when buying full version!", e); } }
From source file:org.anhonesteffort.flock.registration.model.FlockAccount.java
public static Optional<FlockAccount> build(Bundle bundledAccount) throws JsonParseException { if (bundledAccount == null || bundledAccount.getString(KEY_ACCOUNT_ID) == null) return Optional.absent(); Integer planType = bundledAccount.getInt(KEY_SUBSCRIPTION_PLAN_TYPE); String serializedPlan = bundledAccount.getString(KEY_SUBSCRIPTION_PLAN); SubscriptionPlan subscriptionPlan = SubscriptionPlan.buildFromSerialized(planType, serializedPlan); return Optional.of(new FlockAccount(bundledAccount.getString(KEY_ACCOUNT_ID), bundledAccount.getInt(KEY_VERSION), bundledAccount.getString(KEY_SALT), bundledAccount.getString(KEY_PASSWORD_SHA512), bundledAccount.getString(KEY_STRIPE_CUSTOMER_ID), new Date(bundledAccount.getLong(KEY_CREATE_DATE)), bundledAccount.getBoolean(KEY_LAST_STRIPE_CHARGE_FAILED), bundledAccount.getBoolean(KEY_AUTO_RENEW_ENABLED), subscriptionPlan)); }
From source file:androidx.media.SessionToken2.java
/** * Create a token from the bundle, exported by {@link #toBundle()}. * * @param bundle//from ww w . j a v a2 s. c om * @return */ public static SessionToken2 fromBundle(@NonNull Bundle bundle) { if (bundle == null) { return null; } final int uid = bundle.getInt(KEY_UID); final @TokenType int type = bundle.getInt(KEY_TYPE, -1); final String packageName = bundle.getString(KEY_PACKAGE_NAME); final String serviceName = bundle.getString(KEY_SERVICE_NAME); final String id = bundle.getString(KEY_ID); final MediaSessionCompat.Token token = bundle.getParcelable(KEY_SESSION_TOKEN); // Sanity check. switch (type) { case TYPE_SESSION: if (token == null) { throw new IllegalArgumentException( "Unexpected token for session," + " SessionCompat.Token=" + token); } break; case TYPE_SESSION_SERVICE: case TYPE_LIBRARY_SERVICE: if (TextUtils.isEmpty(serviceName)) { throw new IllegalArgumentException("Session service needs service name"); } break; default: throw new IllegalArgumentException("Invalid type"); } if (TextUtils.isEmpty(packageName) || id == null) { throw new IllegalArgumentException("Package name nor ID cannot be null."); } return new SessionToken2(uid, type, packageName, serviceName, id, token); }