Example usage for android.os Bundle putStringArrayList

List of usage examples for android.os Bundle putStringArrayList

Introduction

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

Prototype

@Override
public void putStringArrayList(@Nullable String key, @Nullable ArrayList<String> value) 

Source Link

Document

Inserts an ArrayList value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:air.com.snagfilms.cast.chromecast.utils.Utils.java

/**
 * Builds and returns a {@link Bundle} which contains a select subset of
 * data in the {@link MediaInfo}. Since {@link MediaInfo} is not
 * {@link Parcelable}, one can use this container bundle to pass around from
 * one activity to another./*ww w.ja v a  2s  .  co m*/
 * 
 * @see <code>toMediaInfo()</code>
 * @param info
 * @return
 */
public static Bundle fromMediaInfo(MediaInfo info) {
    if (null == info) {
        return null;
    }

    MediaMetadata md = info.getMetadata();
    Bundle wrapper = new Bundle();
    wrapper.putString(MediaMetadata.KEY_TITLE, md.getString(MediaMetadata.KEY_TITLE));
    wrapper.putString(MediaMetadata.KEY_SUBTITLE, md.getString(MediaMetadata.KEY_SUBTITLE));
    wrapper.putString(KEY_URL, info.getContentId());
    wrapper.putString(MediaMetadata.KEY_STUDIO, md.getString(MediaMetadata.KEY_STUDIO));
    wrapper.putString(KEY_CONTENT_TYPE, info.getContentType());
    wrapper.putInt(KEY_STREAM_TYPE, info.getStreamType());
    if (!md.getImages().isEmpty()) {
        ArrayList<String> urls = new ArrayList<String>();
        for (WebImage img : md.getImages()) {
            urls.add(img.getUrl().toString());
        }
        wrapper.putStringArrayList(KEY_IMAGES, urls);
    }
    JSONObject customData = info.getCustomData();
    if (null != customData) {
        wrapper.putString(KEY_CUSTOM_DATA, customData.toString());
    }

    return wrapper;
}

From source file:org.hedgewars.hedgeroid.TeamAddDialog.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putStringArrayList(STATE_TEAMS_ALREADY_IN_GAME, teamsAlreadyInGame);
}

From source file:com.example.google.location.GeoFenceIntentReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    if (!intent.getAction().equals(LocationActivity.ACTION_GEOFENCE)) {
        return;//w  ww  .j  av  a  2  s .c  o  m
    }
    boolean hasError = LocationClient.hasError(intent);
    if (hasError) {
        // This is an intent that indicates error.
        Log.v(LocationActivity.TAG, "hasError == true");
        return;
    }
    int transition = LocationClient.getGeofenceTransition(intent);
    List<Geofence> list = LocationClient.getTriggeringGeofences(intent);
    if (transition == -1 || list == null) {
        Log.v(LocationActivity.TAG, "list == null OR " + transition);
        return;
    }
    Log.v(LocationActivity.TAG, "geo_fence transition == " + transition);
    ArrayList<String> requestIds = new ArrayList<String>();
    for (Geofence geoFence : list) {
        requestIds.add(geoFence.getRequestId());
    }
    Bundle bundle = new Bundle();
    bundle.putStringArrayList("request_ids", requestIds);

    // Create a new intent and set extra arguments which contain the
    // request_ids of geofences triggered and corresponding transition.
    Intent myIntent = new Intent(context, LocationActivity.class);
    myIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
    myIntent.putExtra("RECEIVER_STARTED", true);
    myIntent.putExtra("geo_fences", bundle);
    myIntent.putExtra("transition", transition);

    if (LocationActivity.isAppForeground) {
        context.startActivity(myIntent);
    } else {
        // Send a notification when the app is in the background
        String transitionText = transition == Geofence.GEOFENCE_TRANSITION_ENTER
                ? context.getResources().getString(R.string.enter)
                : context.getResources().getString(R.string.leave);

        Bitmap genFenceBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.geofence);

        Notification n = new NotificationCompat.Builder(context)
                .setContentTitle(context.getResources().getString(R.string.app_name))
                .setSmallIcon(R.drawable.ic_notify).setDefaults(Notification.DEFAULT_SOUND)
                .setStyle(new NotificationCompat.BigPictureStyle()
                        .bigPicture(genFenceBitmap).setSummaryText(transitionText))
                .setContentText(transitionText)
                .setContentIntent(
                        PendingIntent.getActivity(context, 0, myIntent, PendingIntent.FLAG_UPDATE_CURRENT))
                .setAutoCancel(true).build();

        NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        nm.notify(1, n);
    }
}

From source file:es.glasspixel.wlanaudit.activities.KeyListActivity.java

/**
 * Lifecycle management: Activity state is saved to be restored later
 */// w ww .  ja va 2  s . co  m
protected void onSaveInstanceState(Bundle outState) {
    outState.putStringArrayList(KeyListActivity.KEY_LIST_KEY, (ArrayList<String>) mKeyList);
}

From source file:com.secbro.qark.exportedcomponent.exportedreceiver.IntentSenderFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putStringArrayList(IntentSenderActivity.INTENT_KEYS, keys);
    outState.putString(ExportedReceiverListFragment.EXPORTED_RECEIVER_NAME, exportedReceiverName);
    outState.putString(ExportedReceiverListFragment.EXPORTED_RECEIVER_ID, exportedReceiverId);
}

From source file:com.mb.android.playbackmediator.utils.Utils.java

/**
 * Builds and returns a {@link android.os.Bundle} which contains a select subset of data in the
 * {@link MediaInfo}. Since {@link MediaInfo} is not {@link android.os.Parcelable}, one can use this
 * container bundle to pass around from one activity to another.
 *
 * @param info//ww  w. j a  va 2s  .co  m
 * @return
 * @see <code>toMediaInfo()</code>
 */
public static Bundle fromMediaInfo(MediaInfo info) {
    if (null == info) {
        return null;
    }

    MediaMetadata md = info.getMetadata();
    Bundle wrapper = new Bundle();
    wrapper.putString(MediaMetadata.KEY_TITLE, md.getString(MediaMetadata.KEY_TITLE));
    wrapper.putString(MediaMetadata.KEY_SUBTITLE, md.getString(MediaMetadata.KEY_SUBTITLE));
    wrapper.putString(KEY_URL, info.getContentId());
    wrapper.putString(MediaMetadata.KEY_STUDIO, md.getString(MediaMetadata.KEY_STUDIO));
    wrapper.putString(KEY_CONTENT_TYPE, info.getContentType());
    wrapper.putInt(KEY_STREAM_TYPE, info.getStreamType());
    wrapper.putLong(KEY_STREAM_DURATION, info.getStreamDuration());
    if (!md.getImages().isEmpty()) {
        ArrayList<String> urls = new ArrayList<String>();
        for (WebImage img : md.getImages()) {
            urls.add(img.getUrl().toString());
        }
        wrapper.putStringArrayList(KEY_IMAGES, urls);
    }
    JSONObject customData = info.getCustomData();
    if (null != customData) {
        wrapper.putString(KEY_CUSTOM_DATA, customData.toString());
    }

    return wrapper;
}

From source file:com.liferay.mobile.pushnotifications.list.DDLListView.java

@Override
protected Parcelable onSaveInstanceState() {
    Parcelable superState = super.onSaveInstanceState();

    Bundle state = new Bundle();
    DDLListScreenlet screenlet = (DDLListScreenlet) getParent();
    state.putStringArrayList(STATE_LABEL_FIELDS, (ArrayList<String>) screenlet.getLabelFields());
    state.putParcelable(STATE_SUPER, superState);

    return state;
}

From source file:com.google.android.libraries.cast.companionlibrary.utils.Utils.java

/**
 * Builds and returns a {@link Bundle} which contains a select subset of data in the
 * {@link MediaInfo}. Since {@link MediaInfo} is not {@link Parcelable}, one can use this
 * container bundle to pass around from one activity to another.
 *
 * @see <code>bundleToMediaInfo()</code>
 *///  ww  w  . j a  v a2s.  c o  m
public static Bundle mediaInfoToBundle(MediaInfo info) {
    if (info == null) {
        return null;
    }

    MediaMetadata md = info.getMetadata();
    Bundle wrapper = new Bundle();
    wrapper.putString(MediaMetadata.KEY_TITLE, md.getString(MediaMetadata.KEY_TITLE));
    wrapper.putString(MediaMetadata.KEY_SUBTITLE, md.getString(MediaMetadata.KEY_SUBTITLE));
    wrapper.putString(KEY_URL, info.getContentId());
    wrapper.putString(MediaMetadata.KEY_STUDIO, md.getString(MediaMetadata.KEY_STUDIO));
    wrapper.putString(KEY_CONTENT_TYPE, info.getContentType());
    wrapper.putInt(KEY_STREAM_TYPE, info.getStreamType());
    wrapper.putLong(KEY_STREAM_DURATION, info.getStreamDuration());
    if (!md.getImages().isEmpty()) {
        ArrayList<String> urls = new ArrayList<>();
        for (WebImage img : md.getImages()) {
            urls.add(img.getUrl().toString());
        }
        wrapper.putStringArrayList(KEY_IMAGES, urls);
    }
    JSONObject customData = info.getCustomData();
    if (customData != null) {
        wrapper.putString(KEY_CUSTOM_DATA, customData.toString());
    }
    if (info.getMediaTracks() != null && !info.getMediaTracks().isEmpty()) {
        try {
            JSONArray jsonArray = new JSONArray();
            for (MediaTrack mt : info.getMediaTracks()) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(KEY_TRACK_NAME, mt.getName());
                jsonObject.put(KEY_TRACK_CONTENT_ID, mt.getContentId());
                jsonObject.put(KEY_TRACK_ID, mt.getId());
                jsonObject.put(KEY_TRACK_LANGUAGE, mt.getLanguage());
                jsonObject.put(KEY_TRACK_TYPE, mt.getType());
                if (mt.getSubtype() != MediaTrack.SUBTYPE_UNKNOWN) {
                    jsonObject.put(KEY_TRACK_SUBTYPE, mt.getSubtype());
                }
                if (mt.getCustomData() != null) {
                    jsonObject.put(KEY_TRACK_CUSTOM_DATA, mt.getCustomData().toString());
                }
                jsonArray.put(jsonObject);
            }
            wrapper.putString(KEY_TRACKS_DATA, jsonArray.toString());
        } catch (JSONException e) {
            LOGE(TAG, "mediaInfoToBundle(): Failed to convert Tracks data to json", e);
        }
    }

    return wrapper;
}

From source file:com.auth0.lock.util.LockFragmentBuilder.java

public Fragment social() {
    final SocialFragment fragment = new SocialFragment();
    if (lock.getConfiguration() != null) {
        Bundle bundle = new Bundle();
        bundle.putStringArrayList(SocialFragment.SOCIAL_FRAGMENT_STRATEGIES_ARGUMENT, activeSocialStrategies());
        bundle.putSerializable(BaseTitledFragment.AUTHENTICATION_PARAMETER_ARGUMENT,
                new HashMap<>(lock.getAuthenticationParameters()));
        fragment.setArguments(bundle);//w w  w  . j a  v  a 2s. co  m
    }
    return fragment;
}

From source file:com.oasisfeng.nevo.decorators.bundle.NotificationBundle.java

private void save(final String bundle) {
    final Collection<String> keys = mBundledNotificationKeys.get(bundle);
    final Bundle data = new Bundle();
    data.putStringArrayList(bundle, Lists.newArrayList(keys));
}