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 getMetaData(Context context, String key) {
    Bundle metaData = null;
    String value = null;//ww w .  j  a  v a 2s  .  com
    if (context == null || key == null) {
        return null;
    }
    try {
        ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(),
                PackageManager.GET_META_DATA);
        if (null != ai) {
            metaData = ai.metaData;
        }
        if (null != metaData) {
            value = metaData.getString(key);
        }
    } catch (PackageManager.NameNotFoundException e) {
        // Nothing to do
    }
    return value;
}

From source file:Main.java

public static String getMetaValue(Context context, String metaKey) {
    Bundle metaData = null;
    String apiKey = null;//from   w w  w  . j a  va2  s . c  o m
    if (context == null || metaKey == null) {
        return null;
    }
    try {
        ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(),
                PackageManager.GET_META_DATA);
        if (null != ai) {
            metaData = ai.metaData;
        }
        if (null != metaData) {
            apiKey = metaData.getString(metaKey);
        }
    } catch (PackageManager.NameNotFoundException e) {

    }
    return apiKey;
}

From source file:Main.java

public static String getMetaValue(Context context, String metaKey) {
    Bundle metaData = null;
    String apiKey = null;// w w w .java 2 s  .  c  o  m
    if (context == null || metaKey == null) {
        return null;
    }
    try {
        ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(),
                PackageManager.GET_META_DATA);
        if (null != ai) {
            metaData = ai.metaData;
        }
        if (null != metaData) {
            apiKey = metaData.getString(metaKey);
        }
    } catch (NameNotFoundException e) {

    }
    return apiKey;
}

From source file:Main.java

public static String getMetaValue(Context context, String metaKey) {
    Bundle metaData = null;
    String apiKey = null;/*from www  . j a  v  a2  s . c  om*/
    if (context == null || metaKey == null) {
        return null;
    }
    try {
        ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(),
                PackageManager.GET_META_DATA);
        if (null != ai) {
            metaData = ai.metaData;
        }
        if (null != metaData) {
            apiKey = metaData.getString(metaKey);
        }
    } catch (NameNotFoundException e) {
        Log.e(TAG, "error " + e.getMessage());
    }
    return apiKey;
}

From source file:Main.java

public static String getMetaValue(Context context, String metaKey) {
    Bundle metaData = null;
    String metaValue = null;//from w w w  . ja  v a2s.co  m
    if (context == null || metaKey == null) {
        return null;
    }
    try {
        ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(),
                PackageManager.GET_META_DATA);
        if (null != ai) {
            metaData = ai.metaData;
        }
        if (null != metaData) {
            metaValue = metaData.getString(metaKey);
        }
    } catch (NameNotFoundException e) {

    }
    return metaValue;
}

From source file:com.facebook.login.LoginMethodHandler.java

static AccessToken createAccessTokenFromNativeLogin(Bundle bundle, AccessTokenSource source,
        String applicationId) {/*from  ww  w  . jav  a 2 s .com*/
    Date expires = Utility.getBundleLongAsDate(bundle, NativeProtocol.EXTRA_EXPIRES_SECONDS_SINCE_EPOCH,
            new Date(0));
    ArrayList<String> permissions = bundle.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
    String token = bundle.getString(NativeProtocol.EXTRA_ACCESS_TOKEN);

    if (Utility.isNullOrEmpty(token)) {
        return null;
    }

    String userId = bundle.getString(NativeProtocol.EXTRA_USER_ID);

    return new AccessToken(token, applicationId, userId, permissions, null, source, expires, new Date());
}

From source file:com.facebook.notifications.NotificationsManager.java

@Nullable
private static JSONObject getPushJSON(@NonNull Bundle bundle) throws JSONException {
    String pushPayload = bundle.getString(PUSH_PAYLOAD_KEY);
    if (pushPayload == null) {
        return null;
    }/*w w w.  j a v  a 2 s . co  m*/
    return new JSONObject(pushPayload);
}

From source file:com.facebook.notifications.NotificationsManager.java

@Nullable
private static JSONObject getCardJSON(@NonNull Bundle bundle) throws JSONException {
    String cardPayload = bundle.getString(CARD_PAYLOAD_KEY);
    if (cardPayload == null) {
        return null;
    }//  www  . j av  a2s . c  o m

    return new JSONObject(cardPayload);
}

From source file:com.firefly.sample.castcompanionlibrary.utils.Utils.java

/**
 * Builds and returns a {@link MediaInfo} that was wrapped in a {@link Bundle} by
 * <code>fromMediaInfo</code>.
 *
 * @see <code>fromMediaInfo()</code>
 * @param wrapper/*w  w w.j  av a  2  s  .c o m*/
 * @return
 */
public static MediaInfo toMediaInfo(Bundle wrapper) {
    if (null == wrapper) {
        return null;
    }

    MediaMetadata metaData = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);

    metaData.putString(MediaMetadata.KEY_SUBTITLE, wrapper.getString(MediaMetadata.KEY_SUBTITLE));
    metaData.putString(MediaMetadata.KEY_TITLE, wrapper.getString(MediaMetadata.KEY_TITLE));
    metaData.putString(MediaMetadata.KEY_STUDIO, wrapper.getString(MediaMetadata.KEY_STUDIO));
    ArrayList<String> images = wrapper.getStringArrayList(KEY_IMAGES);
    if (null != images && !images.isEmpty()) {
        for (String url : images) {
            Uri uri = Uri.parse(url);
            metaData.addImage(new WebImage(uri));
        }
    }
    String customDataStr = wrapper.getString(KEY_CUSTOM_DATA);
    JSONObject customData = null;
    if (!TextUtils.isEmpty(customDataStr)) {
        try {
            customData = new JSONObject(customDataStr);
        } catch (JSONException e) {
            LOGE(TAG, "Failed to deserialize the custom data string: custom data= " + customDataStr);
        }
    }
    return new MediaInfo.Builder(wrapper.getString(KEY_URL)).setStreamType(wrapper.getInt(KEY_STREAM_TYPE))
            .setContentType(wrapper.getString(KEY_CONTENT_TYPE)).setMetadata(metaData).setCustomData(customData)
            .build();
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppReferenceObj.java

public static DbObject forFixedMembership(Bundle params, String[] membership, String feedName,
        String groupUri) {/*  w  w  w .  j a  v a2s. c o m*/

    JSONObject json = new JSONObject();
    try {
        JSONArray mship = new JSONArray();
        for (String m : membership) {
            mship.put(m);
        }

        json.put(PACKAGE_NAME, params.getString(PACKAGE_NAME));
        json.put(OBJ_INTENT_ACTION, params.getString(OBJ_INTENT_ACTION)); // todo: pendingIntent? parcelable?
        json.put(Multiplayer.OBJ_MEMBERSHIP, mship);
        json.put(DbObject.CHILD_FEED_NAME, feedName);
        json.put(GROUP_URI, groupUri);
    } catch (JSONException e) {
    }
    return new DbObject(TYPE, json);
}