List of usage examples for android.os Bundle getString
@Nullable
public String getString(@Nullable String key)
From source file:com.chess.genesis.data.GameParser.java
public static JSONObject export(final Bundle data) throws JSONException { final JSONObject game = new JSONObject(); // check if game is a local game final String name; if (data.getString("name") == null) { name = data.getString("white") + " Vs. " + data.getString("black"); game.put("eventtype", Enums.EventType(Integer.parseInt(data.getString("gametype")))); } else {/*from w ww . ja v a 2 s. c o m*/ name = data.getString("name"); game.put("opponent", Enums.OpponentType(Integer.parseInt(data.getString("opponent")))); } game.put("name", name); game.put("gametype", Enums.GameType(Integer.parseInt(data.getString("gametype")))); game.put("history", data.getString("history")); return game; }
From source file:Main.java
public static String encodeUrl(Bundle parameters, boolean sep) { String query = ""; int x = 0;//from w w w. j ava2 s .c o m for (String key : parameters.keySet()) { String q = "?"; if (sep == false) q = "&"; query += (x == 0 ? q : "&") + key + "=" + parameters.getString(key); x++; } return query; }
From source file:com.ademsha.appnotifico.NotificationDataHelper.java
@TargetApi(Build.VERSION_CODES.KITKAT) private static JSONObject getNotificationExtras(JSONObject notification, StatusBarNotification statusBarNotification) { try {//from w w w .j av a 2s . c o m Bundle extras = statusBarNotification.getNotification().extras; if (extras != null) { notification.put("text", extras.getString(Notification.EXTRA_TEXT)); notification.put("sub_text", extras.getString(Notification.EXTRA_SUB_TEXT)); notification.put("summary_text", extras.getString(Notification.EXTRA_SUMMARY_TEXT)); notification.put("text_lines", Arrays .toString(extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES)).replace("null", "")); notification.put("icon", String.valueOf(extras.getInt(Notification.EXTRA_SMALL_ICON))); if (extras.getParcelable(Notification.EXTRA_LARGE_ICON) != null) { notification.put("large_icon", String.valueOf(extras.getParcelable(Notification.EXTRA_LARGE_ICON).toString()) .replace("null", "")); } notification.put("title", extras.getString(Notification.EXTRA_TITLE)); notification.put("title_big", extras.getString(Notification.EXTRA_TITLE_BIG)); notification.put("progress", extras.getInt(Notification.EXTRA_PROGRESS)); notification.put("progress_indeterminate", String.valueOf(extras.getBoolean(Notification.EXTRA_PROGRESS_INDETERMINATE))); notification.put("progress_max", String.valueOf(extras.getInt(Notification.EXTRA_PROGRESS_MAX))); notification.put("people", extras.getStringArray(Notification.EXTRA_PEOPLE)); } } catch (JSONException e) { e.printStackTrace(); } return notification; }
From source file:Main.java
public static Map<String, String> bundleToMap(Bundle extras) { Map<String, String> map = new HashMap<String, String>(); Set<String> ks = extras.keySet(); Iterator<String> iterator = ks.iterator(); while (iterator.hasNext()) { String key = iterator.next(); map.put(key, extras.getString(key)); }/* ww w .j a v a 2 s . co m*/ return map; }
From source file:Main.java
public static String getAppMetadata(Context context, String key) { String strValue = ""; try {// w w w .j ava 2 s. co m PackageManager mgr = context.getPackageManager(); Bundle bundle = mgr.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA).metaData; //Bundle bundle = context.getApplicationInfo().metaData; if (bundle != null && bundle.containsKey(key)) { strValue = bundle.getString(key); } } catch (Exception e) { Log.w(LOG_TAG, e); } return strValue; }
From source file:com.microsoft.azure.engagement.unity.EngagementWrapper.java
public static void registerApp(String _instanceName, String _connectionString, int _locationType, int _locationMode, boolean _enablePluginLog) { unityObjectName = _instanceName;//ww w . j a va 2 s . c o m if (androidActivity == null) { Log.e(EngagementShared.LOG_TAG, "missing AndroidActivty (setAndroidActivity() not being called?)"); return; } if (EngagementShared.instance().alreadyInitialized()) { Log.e(EngagementShared.LOG_TAG, "registerApp() already called"); return; } try { ApplicationInfo ai = androidActivity.getPackageManager() .getApplicationInfo(androidActivity.getPackageName(), PackageManager.GET_META_DATA); Bundle bundle = ai.metaData; String mfPluginVersion = bundle.getString("engagement:unity:version"); if (mfPluginVersion == null) throw new PackageManager.NameNotFoundException(); if (pluginVersion.equals(mfPluginVersion) == false) Log.i(EngagementShared.LOG_TAG, "Unity Plugin Version (" + pluginVersion + ") does not match manifest version (" + mfPluginVersion + ") : Manifest might need to be regenerated"); } catch (Exception e) { Log.e(EngagementShared.LOG_TAG, "Cannot find engagement:unity:version in Android Manifest : Manifest file needs to be generated through File/Engagement/Generate Android Manifest"); } EngagementShared.instance().setPluginLog(_enablePluginLog); EngagementShared.instance().initSDK(pluginName, pluginVersion, nativeVersion); EngagementShared.instance().setDelegate(engagementDelegate); EngagementShared.locationReportingType locationReporting = EngagementShared.locationReportingType .fromInteger(_locationType); EngagementShared.backgroundReportingType background = EngagementShared.backgroundReportingType .fromInteger(_locationMode); EngagementShared.instance().initialize(androidActivity, _connectionString, locationReporting, background); // We consider the app to be active on registerApp as onResume() is not being automatically called EngagementShared.instance().onResume(); }
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: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 {// w w w . j a v a 2 s . co m return null; } }
From source file:com.scoreflex.ScoreflexGcmClient.java
/** * Start the registration process for GCM. * @param senderID The sender ID to register to. * @param context A valid context//from w ww .j a v a 2 s .com */ @SuppressLint("NewApi") public static void registerForPushNotification(Context context) { String regid = getRegistrationId(context); String pushSenderId = null; try { ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); Bundle bundle = ai.metaData; pushSenderId = bundle.getString("com.scoreflex.push.SenderId"); } catch (NameNotFoundException e) { Log.e("Scoreflex", "Could not get com.scoreflex.push.SenderId meta data from your manifest did you add : <meta-data android:name=\"com.scoreflex.push.SenderId\" android:value=\"@string/push_sender_id\"/>"); } catch (NullPointerException e) { Log.e("Scoreflex", "Could not get com.scoreflex.push.SenderId meta data from your manifest did you add : <meta-data android:name=\"com.scoreflex.push.SenderId\" android:value=\"@string/push_sender_id\"/>"); } if (pushSenderId == null) { return; } if (TextUtils.isEmpty(regid)) { registerInBackground(pushSenderId, context); } else { storeRegistrationIdToScoreflex(regid); } return; }
From source file:Main.java
public static String encodePostParams(Bundle params) { StringBuilder sb = new StringBuilder(); boolean and = true; for (String key : params.keySet()) { if (!and) { sb.append("&"); }/*from w ww. j av a 2 s . c om*/ sb.append(key + "=" + params.getString(key)); and = false; } return sb.toString(); }