List of usage examples for android.os Bundle getString
@Nullable
public String getString(@Nullable String key)
From source file:com.eurotong.orderhelperandroid.Common.java
public static Table GetTableFromIntent(Activity activity) { Table table = null;/*from w w w . j av a 2s. c o m*/ Bundle extras = activity.getIntent().getExtras(); if (extras != null) { String tablenr = extras.getString(Define.TABLE_NR); if (tablenr != null && tablenr != "") { table = TableHelper.GetTableByNumber(tablenr); } } return table; }
From source file:com.amazon.android.contentbrowser.helper.AuthHelper.java
/** * Convert auth error to utils error.// w w w . ja v a2 s . c o m * * @param bundle Auth error bundle. * @return Error category. */ public static ErrorUtils.ERROR_CATEGORY convertAuthErrorToErrorUtils(Bundle bundle) { switch (bundle.getString(AuthenticationConstants.ERROR_CATEGORY)) { case AuthenticationConstants.REGISTRATION_ERROR_CATEGORY: return ErrorUtils.ERROR_CATEGORY.REGISTRATION_CODE_ERROR; case AuthenticationConstants.NETWORK_ERROR_CATEGORY: return ErrorUtils.ERROR_CATEGORY.NETWORK_ERROR; case AuthenticationConstants.AUTHENTICATION_ERROR_CATEGORY: return ErrorUtils.ERROR_CATEGORY.AUTHENTICATION_ERROR; case AuthenticationConstants.AUTHORIZATION_ERROR_CATEGORY: return ErrorUtils.ERROR_CATEGORY.AUTHORIZATION_ERROR; } return ErrorUtils.ERROR_CATEGORY.NETWORK_ERROR; }
From source file:edu.stanford.junction.android.AndroidJunctionMaker.java
public static Junction newJunction(Intent intent, JunctionActor actor) throws JunctionException { Bundle bundle = intent.getExtras(); if (bundle == null || !bundle.containsKey(Intents.EXTRA_ACTIVITY_SESSION_URI)) { throw new JunctionException("No session uri found."); }/*from w ww .jav a 2s.c om*/ URI uri = URI.create(bundle.getString(Intents.EXTRA_ACTIVITY_SESSION_URI)); SwitchboardConfig cfg = AndroidJunctionMaker.getDefaultSwitchboardConfig(uri); AndroidJunctionMaker maker = AndroidJunctionMaker.getInstance(cfg); ActivityScript script = null; if (bundle.containsKey(Intents.EXTRA_ACTIVITY_SCRIPT)) { try { JSONObject json = new JSONObject(bundle.getString(Intents.EXTRA_ACTIVITY_SCRIPT)); script = new ActivityScript(json); } catch (JSONException e) { throw new JunctionException("Bad activity script in Intent.", e); } } return maker.newJunction(uri, script, actor); }
From source file:com.bpd.facebook.Util.java
/** * Connect to an HTTP URL and return the response as a string. * * Note that the HTTP method override is used on non-GET requests. (i.e. * requests are made as "POST" with method specified in the body). * * @param url - the resource to open: must be a welformed URL * @param method - the HTTP method to use ("GET", "POST", etc.) * @param params - the query parameter for the URL (e.g. access_token=foo) * @return the URL contents as a String//w ww . j a va2 s . c o m * @throws MalformedURLException - if the URL format is invalid * @throws IOException - if a network problem occurs */ public static String openUrl(String url, String method, Bundle params) throws MalformedURLException, IOException { // random string as boundary for multi-part http post String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f"; String endLine = "\r\n"; OutputStream os; // Try to get filename key String filename = params.getString("filename"); // If found if (filename != null) { // Remove from params params.remove("filename"); } if (method.equals("GET")) { url = url + "?" + encodeUrl(params); } Log.d("Facebook-Util", method + " URL: " + url); HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " FacebookAndroidSDK"); if (!method.equals("GET")) { Bundle dataparams = new Bundle(); for (String key : params.keySet()) { if (params.getByteArray(key) != null) { dataparams.putByteArray(key, params.getByteArray(key)); } } // use method override if (!params.containsKey("method")) { params.putString("method", method); } if (params.containsKey("access_token")) { String decoded_token = URLDecoder.decode(params.getString("access_token")); params.putString("access_token", decoded_token); } conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestProperty("Connection", "Keep-Alive"); conn.connect(); os = new BufferedOutputStream(conn.getOutputStream()); os.write(("--" + strBoundary + endLine).getBytes()); os.write((encodePostBody(params, strBoundary)).getBytes()); os.write((endLine + "--" + strBoundary + endLine).getBytes()); if (!dataparams.isEmpty()) { for (String key : dataparams.keySet()) { os.write(("Content-Disposition: form-data; filename=\"" + ((filename != null) ? filename : key) + "\"" + endLine).getBytes()); os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes()); os.write(dataparams.getByteArray(key)); os.write((endLine + "--" + strBoundary + endLine).getBytes()); } } os.flush(); } String response = ""; try { response = read(conn.getInputStream()); } catch (FileNotFoundException e) { // Error Stream contains JSON that we can parse to a FB error response = read(conn.getErrorStream()); } return response; }
From source file:com.captix.scan.social.facebook.Util.java
@SuppressWarnings("deprecation") public static String encodeUrl(Bundle parameters) { if (parameters == null) { return ""; }/*ww w. java 2 s . c o m*/ StringBuilder sb = new StringBuilder(); boolean first = true; for (String key : parameters.keySet()) { if (first) first = false; else sb.append("&"); sb.append(URLEncoder.encode(key) + "=" + URLEncoder.encode(parameters.getString(key))); } return sb.toString(); }
From source file:com.facebook.android.library.Util.java
/** * Generate the multi-part post body providing the parameters and boundary * string// ww w . ja va 2 s. c o m * * @param parameters * the parameters need to be posted * @param boundary * the random string as boundary * @return a string of the post body */ public static String encodePostBody(Bundle parameters, String boundary) { if (parameters == null) return ""; StringBuilder sb = new StringBuilder(); for (String key : parameters.keySet()) { if (parameters.get(key) instanceof byte[]) { continue; } sb.append("Content-Disposition: form-data; name=\"" + key + "\"\r\n\r\n" + parameters.getString(key)); sb.append("\r\n" + "--" + boundary + "\r\n"); } return sb.toString(); }
From source file:com.actionlauncher.api.LiveWallpaperInfo.java
/** * Deserializes an liveWallpaperInfo object from a {@link Bundle}. */// w ww .jav a 2s. c o m public static LiveWallpaperInfo fromBundle(Bundle bundle) { return new Builder().token(bundle.getString(KEY_TOKEN)) .paletteVibrantRgb(bundle.getString(KEY_PALETTE_VIBRANT_RGB, null)) .paletteVibrantTitleTextRgb(bundle.getString(KEY_PALETTE_VIBRANT_TITLE_TEXT, null)) .paletteVibrantBodyTextRgb(bundle.getString(KEY_PALETTE_VIBRANT_BODY_TEXT, null)) .paletteLightVibrantRgb(bundle.getString(KEY_PALETTE_LIGHT_VIBRANT_RGB, null)) .paletteLightVibrantTitleTextRgb(bundle.getString(KEY_PALETTE_LIGHT_VIBRANT_TITLE_TEXT, null)) .paletteLightVibrantBodyTextRgb(bundle.getString(KEY_PALETTE_LIGHT_VIBRANT_BODY_TEXT, null)) .paletteDarkVibrantRgb(bundle.getString(KEY_PALETTE_DARK_VIBRANT_RGB, null)) .paletteDarkVibrantTitleTextRgb(bundle.getString(KEY_PALETTE_DARK_VIBRANT_TITLE_TEXT, null)) .paletteDarkVibrantBodyTextRgb(bundle.getString(KEY_PALETTE_DARK_VIBRANT_BODY_TEXT, null)) .paletteMutedRgb(bundle.getString(KEY_PALETTE_MUTED_RGB, null)) .paletteMutedTitleTextRgb(bundle.getString(KEY_PALETTE_MUTED_TITLE_TEXT, null)) .paletteMutedBodyTextRgb(bundle.getString(KEY_PALETTE_MUTED_BODY_TEXT, null)) .paletteLightMutedRgb(bundle.getString(KEY_PALETTE_LIGHT_MUTED_RGB, null)) .paletteLightMutedTitleTextRgb(bundle.getString(KEY_PALETTE_LIGHT_MUTED_TITLE_TEXT, null)) .paletteLightMutedBodyTextRgb(bundle.getString(KEY_PALETTE_LIGHT_MUTED_BODY_TEXT, null)) .paletteDarkMutedRgb(bundle.getString(KEY_PALETTE_DARK_MUTED_RGB, null)) .paletteDarkMutedTitleTextRgb(bundle.getString(KEY_PALETTE_DARK_MUTED_TITLE_TEXT, null)) .paletteDarkMutedBodyTextRgb(bundle.getString(KEY_PALETTE_DARK_MUTED_BODY_TEXT, null)).build(); }
From source file:cz.muni.fi.japanesedictionary.entity.Translation.java
/** * Creates new instance of Translation from saved instance in given bundle. * /* ww w. ja v a2 s .c o m*/ * @param bundle bundle with saved Translation * @return returns new instance of Translation or null if bundle is null */ public static Translation newInstanceFromBundle(Bundle bundle) { if (bundle == null) { return null; } Translation translation = new Translation(); String japaneseKeb = bundle.getString(SAVE_JAPANESE_KEB); String japaneseReb = bundle.getString(SAVE_JAPANESE_REB); String english = bundle.getString(SAVE_ENGLISH); String french = bundle.getString(SAVE_FRENCH); String dutch = bundle.getString(SAVE_DUTCH); String german = bundle.getString(SAVE_GERMAN); String russian = bundle.getString(SAVE_RUSSIAN); translation.parseJapaneseKeb(japaneseKeb); translation.parseJapaneseReb(japaneseReb); translation.parseEnglish(english); translation.parseFrench(french); translation.parseDutch(dutch); translation.parseGerman(german); translation.parseRussian(russian); translation.setPrioritized(bundle.getBoolean(SAVE_PRIORITIZED)); translation.setRuby(bundle.getString(SAVE_RUBY)); return translation.getJapaneseReb() != null && translation.getJapaneseReb().size() > 0 ? translation : null; }
From source file:com.onesignal.NotificationBundleProcessor.java
public static void Process(Context context, Bundle bundle) { if (OneSignal.isValidAndNotDuplicated(context, bundle)) { boolean showAsAlert = OneSignal.getInAppAlertNotificationEnabled(context); boolean isActive = OneSignal.initDone && OneSignal.isForeground(); boolean display = OneSignal.getNotificationsWhenActiveEnabled(context) || showAsAlert || !isActive; prepareBundle(bundle);// w w w .java 2 s .co m BackgroundBroadcaster.Invoke(context, bundle, isActive); if (!bundle.containsKey("alert") || bundle.getString("alert") == null || bundle.getString("alert").equals("")) return; int notificationId = -1; if (display)// Build notification from the Bundle notificationId = GenerateNotification.fromBundle(context, bundle, showAsAlert && isActive); else { final Bundle finalBundle = bundle; // Current thread is meant to be short lived. Make a new thread to do our OneSignal work on. new Thread(new Runnable() { public void run() { OneSignal.handleNotificationOpened( NotificationBundleProcessor.bundleAsJsonArray(finalBundle)); } }).start(); } saveNotification(context, bundle, !display, notificationId); } }
From source file:barcamp.com.facebook.android.Util.java
/** * Generate the multi-part post body providing the parameters and boundary * string/*from www. j ava 2 s. c om*/ * * @param parameters the parameters need to be posted * @param boundary the random string as boundary * @return a string of the post body */ public static String encodePostBody(Bundle parameters, String boundary) { if (parameters == null) return ""; StringBuilder sb = new StringBuilder(); for (String key : parameters.keySet()) { //if (parameters.getByteArray(key) != null) { if (parameters.get(key) instanceof byte[]) { continue; } sb.append("Content-Disposition: form-data; name=\"" + key + "\"\r\n\r\n" + parameters.getString(key)); sb.append("\r\n" + "--" + boundary + "\r\n"); } return sb.toString(); }