Example usage for android.os Bundle getString

List of usage examples for android.os Bundle getString

Introduction

In this page you can find the example usage for android.os Bundle getString.

Prototype

@Nullable
public String getString(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:org.anhonesteffort.flock.registration.model.FlockCardInformation.java

public static Optional<FlockCardInformation> build(Bundle bundledCardInformation) {
    if (bundledCardInformation == null || bundledCardInformation.getString(KEY_ACCOUNT_ID) == null)
        return Optional.absent();

    return Optional.of(new FlockCardInformation(bundledCardInformation.getString(KEY_ACCOUNT_ID),
            bundledCardInformation.getString(KEY_LAST_FOUR), bundledCardInformation.getString(KEY_EXPIRATION)));
}

From source file:Main.java

public static String interceptStringParam(Bundle savedInstanceState, Intent intent, String paramName) {
    String ret = null;/*  w  w  w .j  a  v a  2  s .  c  o  m*/

    if (savedInstanceState != null) {
        ret = savedInstanceState.getString(paramName);
    } else {
        if (intent != null) {
            Bundle incomming = intent.getExtras();
            if (incomming != null) {
                ret = incomming.getString(paramName);
            }
        }
    }

    return ret;
}

From source file:com.chess.genesis.data.GameParser.java

public static JSONObject parse(final Bundle data) throws JSONException {
    final JSONObject game = export(data);

    game.put("zfen", data.getString("zfen"));
    game.put("ctime", Long.parseLong(data.getString("ctime")));
    game.put("stime", Long.parseLong(data.getString("stime")));

    return game;/*from w w  w .  j  a  v a  2s .  c  o m*/
}

From source file:com.battlelancer.seriesguide.api.Action.java

/**
 * Deserializes a {@link Bundle} into a {@link Action} object.
 *///w  w  w  . jav a2  s  . c o m
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:Main.java

public static String getStringByCaseInsensitive(Bundle bundle, String key) {
    Set<String> keys = bundle.keySet();
    String lower = key.toLowerCase();
    for (String k : keys) {
        if (k.toLowerCase().equals(lower))
            return bundle.getString(k);
    }//from   w ww.jav  a 2  s. co  m

    return null;
}

From source file:sg.macbuntu.android.pushcontacts.DeviceRegistrar.java

private static String getAuthToken(Context context, Account account) {
    String authToken = null;/*  w  ww .  j a v a2 s .  com*/
    AccountManager accountManager = AccountManager.get(context);
    try {
        AccountManagerFuture<Bundle> future = accountManager.getAuthToken(account, AUTH_TOKEN_TYPE, false, null,
                null);
        Bundle bundle = future.getResult();
        authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN);
        // User will be asked for "App Engine" permission.
        if (authToken == null) {
            // No auth token - will need to ask permission from user.
            Intent intent = new Intent(ActivityUI.AUTH_PERMISSION_ACTION);
            intent.putExtra("AccountManagerBundle", bundle);
            context.sendBroadcast(intent);
        }
    } catch (OperationCanceledException e) {
        Log.w(TAG, e.getMessage());
    } catch (AuthenticatorException e) {
        Log.w(TAG, e.getMessage());
    } catch (IOException e) {
        Log.w(TAG, e.getMessage());
    }
    return authToken;
}

From source file:Main.java

/**
 * Returns GET url with appended parameters.
 *
 * @param url//from  w  ww . j  a v  a2s  .  c om
 * @param params
 * @return
 */
public static String toGetUrl(String url, Bundle params) {
    if (params != null) {
        if (!url.endsWith("?")) {
            url = url + "?";
        }

        for (String key : params.keySet()) {
            url = url + key + "=" + params.getString(key) + "&";
        }
    }
    return url;
}

From source file:Main.java

public static String getMetaData(Context app, String name) {
    Bundle bundle = app.getApplicationInfo().metaData;
    if (bundle != null) {
        return bundle.getString(name);
    } else {/*from w w  w  . j a va  2  s  .  co  m*/
        XmlResourceParser parser = null;
        AssetManager assmgr = null;

        try {
            assmgr = (AssetManager) AssetManager.class.newInstance();
            Method e = AssetManager.class.getDeclaredMethod("addAssetPath", new Class[] { String.class });
            e.setAccessible(true);
            int cookie = ((Integer) e.invoke(assmgr, new Object[] { app.getApplicationInfo().sourceDir }))
                    .intValue();
            if (cookie != 0) {
                String ANDROID_RESOURCES = "http://schemas.android.com/apk/res/android";
                parser = assmgr.openXmlResourceParser(cookie, "AndroidManifest.xml");
                boolean findAppMetadata = false;
                int event = parser.getEventType();
                while (event != 1) {
                    switch (event) {
                    case 2:
                        String nodeName = parser.getName();
                        String metadataName;
                        if ("meta-data".equals(nodeName)) {
                            findAppMetadata = true;
                            metadataName = parser.getAttributeValue(ANDROID_RESOURCES, "name");
                            if (metadataName.equals(name)) {
                                String var12 = parser.getAttributeValue(ANDROID_RESOURCES, "value");
                                return var12;
                            }
                        } else if (findAppMetadata) {
                            metadataName = null;
                            return metadataName;
                        }
                    default:
                        event = parser.next();
                    }
                }
            }
        } catch (Throwable var16) {
            var16.printStackTrace();
        } finally {
            if (parser != null) {
                parser.close();
            }

            if (assmgr != null) {
                assmgr.close();
            }

        }

        return null;
    }
}

From source file:com.freshplanet.nativeExtensions.Extension.java

public static String getParametersFromIntent(Intent intent) {
    JSONObject paramsJson = new JSONObject();
    Bundle bundle = intent.getExtras();
    String parameters = intent.getStringExtra("parameters");
    try {//from ww w.ja v a2s .c o  m
        for (String key : bundle.keySet()) {
            paramsJson.put(key, bundle.getString(key));
        }

        if (parameters != null) {
            paramsJson.put("parameters", new JSONObject(parameters));
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return paramsJson.toString();
}

From source file:Main.java

public static String getAppKey(Context paramContext) {
    String str = null;//from  w ww  .  j  ava  2s  . com
    try {
        ApplicationInfo localApplicationInfo = paramContext.getPackageManager()
                .getApplicationInfo(paramContext.getPackageName(), 128);
        Bundle localBundle = null;
        str = null;
        if (localApplicationInfo != null)
            localBundle = localApplicationInfo.metaData;
        str = null;
        if (localBundle != null) {
            str = localBundle.getString("JPUSH_APPKEY");
            if (str != null) {
                int i = str.length();
                if (i == 24)
                    ;
            } else {
                str = null;
            }
        }
        return str;
    } catch (PackageManager.NameNotFoundException localNameNotFoundException) {
    }
    return str;
}