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:Main.java

public static String getString(Bundle arguments, String key) {
    if (arguments.containsKey(key)) {
        return arguments.getString(key);
    } else {/*from w  w w  .j a va2  s.  c o m*/
        return null;
    }
}

From source file:Main.java

public static String getString(Bundle b, String key) {
    String ret = "";
    if (b != null) {
        ret = b.getString(key);
        if (ret == null) {
            ret = "";
        }//from  ww w.  j av a2s. com
    }
    return ret;
}

From source file:Main.java

public static String getIntentString(Intent intent, String value) {
    Bundle extras = intent.getExtras();
    String result = "";
    if (extras != null) {
        result = extras.getString(value);
    }//from ww  w .ja v a 2 s .  c o  m
    return result;
}

From source file:Main.java

public static String getActiviteitNameFromIntent(Intent intent) {
    if (intent == null) {
        return null;
    }/*from www.  j a  va 2s.  c om*/
    Bundle extras = intent.getExtras();
    if (extras == null) {
        return null;
    }
    return extras.getString(ACTIVITEIT_NAME);
}

From source file:Main.java

public static int getIntByString(Bundle bundle, String key, int def) {
    if (bundle == null)
        return def;
    String str = bundle.getString(key);
    if (!TextUtils.isEmpty(str)) {
        try {//  ww  w  . jav a 2s. c  om
            return Integer.parseInt(str);
        } catch (NumberFormatException e) {
            // TODO: handle exception
            e.printStackTrace();
        }
    }

    return def;
}

From source file:Main.java

@NonNull
public static String getString(final Bundle bundle, @NonNull final String key,
        @NonNull final String defaultValue) {
    final String res = bundle.getString(key);
    if (res != null) {
        return res;
    }/*  w ww .  j av a 2s.co m*/
    return defaultValue;
}

From source file:Main.java

public static boolean isCanInstallToExternal(String apkPath, Context context) {
    boolean canExternal = true;
    try {/*from ww  w.j  a v a 2s.c  o  m*/
        PackageInfo info = context.getPackageManager().getPackageArchiveInfo(apkPath,
                PackageManager.GET_META_DATA);

        Bundle bundle = info.applicationInfo.metaData;

        if (bundle != null) {
            String value = bundle.getString("kyx_external");
            if (value != null && value.equals("no")) {
                canExternal = false;
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    return canExternal;
}

From source file:Main.java

public static boolean hasTokenInformation(Bundle bundle) {
    if (bundle == null) {
        return false;
    }/*from w  ww.  ja va  2s.  co  m*/

    String token = bundle.getString(TOKEN_KEY);
    if ((token == null) || (token.length() == 0)) {
        return false;
    }

    long expiresMilliseconds = bundle.getLong(EXPIRATION_DATE_KEY, 0L);
    if (expiresMilliseconds == 0L) {
        return false;
    }

    return true;
}

From source file:Main.java

public static Map<String, String> fromBundle(Bundle input) {
    Map<String, String> output = new HashMap<String, String>();
    for (String key : input.keySet()) {
        output.put(key, input.getString(key));
    }/*  w  w  w  .  j a  v  a 2  s .  co  m*/
    return output;
}

From source file:Main.java

public static String printBundle(Bundle bundle) {
    StringBuilder sb = new StringBuilder();
    for (String key : bundle.keySet()) {
        sb.append("\nkey:" + key + ", value:" + bundle.getString(key));
    }/*from   w ww  .  j  a v  a  2  s. c om*/
    return sb.toString();
}