Java Code Examples for android.os.Bundle#putAll()

The following examples show how to use android.os.Bundle#putAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseActivity.java    From v2ex with Apache License 2.0 6 votes vote down vote up
/**
 * Converts an intent into a {@link Bundle} suitable for use as fragment arguments.
 */
public static Bundle intentToFragmentArguments(Intent intent) {
    Bundle arguments = new Bundle();
    if (intent == null) {
        return arguments;
    }

    final Uri data = intent.getData();
    if (data != null) {
        arguments.putParcelable("_uri", data);
    }

    final Bundle extras = intent.getExtras();
    if (extras != null) {
        arguments.putAll(intent.getExtras());
    }

    return arguments;
}
 
Example 2
Source File: SinglePaneActivity.java    From COCOFramework with Apache License 2.0 6 votes vote down vote up
/**
 * Converts an intent into a {@link Bundle} suitable for use as fragment
 * arguments.
 */
public static Bundle intentToFragmentArguments(final Intent intent) {
    final Bundle arguments = new Bundle();
    if (intent == null) {
        return arguments;
    }

    final Uri data = intent.getData();
    if (data != null) {
        arguments.putParcelable("_uri", data);
    }

    final Bundle extras = intent.getExtras();
    if (extras != null) {
        arguments.putAll(intent.getExtras());
    }

    return arguments;
}
 
Example 3
Source File: BackgroundTaskSchedulerJobService.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves the {@link TaskParameters} from the {@link JobParameters}, which are passed as
 * one of the keys. Only values valid for {@link android.os.BaseBundle} are supported, and other
 * values are stripped at the time when the task is scheduled.
 *
 * @param jobParameters the {@link JobParameters} to extract the {@link TaskParameters} from.
 * @return the {@link TaskParameters} for the current job.
 */
static TaskParameters getTaskParametersFromJobParameters(JobParameters jobParameters) {
    TaskParameters.Builder builder = TaskParameters.create(jobParameters.getJobId());

    PersistableBundle jobExtras = jobParameters.getExtras();
    PersistableBundle persistableTaskExtras =
            jobExtras.getPersistableBundle(BACKGROUND_TASK_EXTRAS_KEY);

    Bundle taskExtras = new Bundle();
    taskExtras.putAll(persistableTaskExtras);
    builder.addExtras(taskExtras);

    return builder.build();
}
 
Example 4
Source File: Util.java    From KlyphMessenger with MIT License 5 votes vote down vote up
/**
 * Parse a URL query and fragment parameters into a key-value bundle.
 *
 * @param url the URL to parse
 * @return a dictionary bundle of keys and values
 */
@Deprecated
public static Bundle parseUrl(String url) {
    // hack to prevent MalformedURLException
    url = url.replace("fbconnect", "http");
    try {
        URL u = new URL(url);
        Bundle b = decodeUrl(u.getQuery());
        b.putAll(decodeUrl(u.getRef()));
        return b;
    } catch (MalformedURLException e) {
        return new Bundle();
    }
}
 
Example 5
Source File: KVUtils.java    From letv with Apache License 2.0 5 votes vote down vote up
public static String toString(Bundle b) {
    if (b == null) {
        return "";
    }
    Bundle bundle = new Bundle();
    bundle.putAll(b);
    return bundle.toString();
}
 
Example 6
Source File: PhotoGallery.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void saveState(Bundle outState) {
    Bundle bundle = (Bundle) super.onSaveInstanceState();
    if (bundle != null) {
        bundle.putIntegerArrayList(BUNDLE_DELETED_IMAGES, new ArrayList<>(getDeletedAttaches()));
        bundle.remove("instanceState");
        outState.putAll(bundle);
    }
}
 
Example 7
Source File: Util.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Parse a URL query and fragment parameters into a key-value bundle.
 *
 * @param url the URL to parse
 * @return a dictionary bundle of keys and values
 */
@Deprecated
public static Bundle parseUrl(String url) {
    // hack to prevent MalformedURLException
    url = url.replace("fbconnect", "http");
    try {
        URL u = new URL(url);
        Bundle b = decodeUrl(u.getQuery());
        b.putAll(decodeUrl(u.getRef()));
        return b;
    } catch (MalformedURLException e) {
        return new Bundle();
    }
}
 
Example 8
Source File: SocialApiIml.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void challenge(Activity activity, Bundle bundle, IUiListener iuilistener)
{
    b = activity;
    Intent intent = getAgentIntentWithTarget("com.tencent.open.agent.ChallengeActivity");
    bundle.putAll(composeActivityParams());
    a(activity, intent, "action_challenge", bundle, ServerSetting.getInstance().getEnvUrl(mContext, "http://qzs.qq.com/open/mobile/brag/sdk_brag.html?"), iuilistener);
}
 
Example 9
Source File: SocialApiIml.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void brag(Activity activity, Bundle bundle, IUiListener iuilistener)
{
    b = activity;
    Intent intent = getAgentIntentWithTarget("com.tencent.open.agent.BragActivity");
    bundle.putAll(composeActivityParams());
    a(activity, intent, "action_brag", bundle, ServerSetting.getInstance().getEnvUrl(mContext, "http://qzs.qq.com/open/mobile/brag/sdk_brag.html?"), iuilistener);
}
 
Example 10
Source File: CocoDialog.java    From COCOFramework with Apache License 2.0 5 votes vote down vote up
public Builder show(final FragmentManager fragmentManager) {
    final Bundle b = new Bundle();
    b.putString("_fragment", fragment.getName());
    if (arg != null) {
        b.putAll(arg);
    }
    final CocoDialog d = new CocoDialog(style);
    d.setArguments(b);
    BaseDialog.show(fragmentManager, d);
    return this;
}
 
Example 11
Source File: BricksListDialogFragment.java    From 4pdaClient-plus with Apache License 2.0 5 votes vote down vote up
static BricksListDialogFragment newInstance(String dialogId, String[] brickNames, Bundle args) {
    BricksListDialogFragment f = new BricksListDialogFragment();
    Bundle arguments = new Bundle();
    arguments.putStringArray(BRICK_NAMES_KEY, brickNames);
    arguments.putString(DIALOG_ID_KEY, dialogId);
    if (args != null)
        arguments.putAll(args);
    f.setArguments(arguments);
    return f;
}
 
Example 12
Source File: FirstRunPage.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putAll(mProperties);
}
 
Example 13
Source File: NotificationCompatKitKat.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
public Builder(Context context, Notification n,
        CharSequence contentTitle, CharSequence contentText, CharSequence contentInfo,
        RemoteViews tickerView, int number,
        PendingIntent contentIntent, PendingIntent fullScreenIntent, Bitmap largeIcon,
        int progressMax, int progress, boolean progressIndeterminate, boolean showWhen,
        boolean useChronometer, int priority, CharSequence subText, boolean localOnly,
        ArrayList<String> people, Bundle extras, String groupKey, boolean groupSummary,
        String sortKey) {
    b = new Notification.Builder(context)
        .setWhen(n.when)
        .setShowWhen(showWhen)
        .setSmallIcon(n.icon, n.iconLevel)
        .setContent(n.contentView)
        .setTicker(n.tickerText, tickerView)
        .setSound(n.sound, n.audioStreamType)
        .setVibrate(n.vibrate)
        .setLights(n.ledARGB, n.ledOnMS, n.ledOffMS)
        .setOngoing((n.flags & Notification.FLAG_ONGOING_EVENT) != 0)
        .setOnlyAlertOnce((n.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0)
        .setAutoCancel((n.flags & Notification.FLAG_AUTO_CANCEL) != 0)
        .setDefaults(n.defaults)
        .setContentTitle(contentTitle)
        .setContentText(contentText)
        .setSubText(subText)
        .setContentInfo(contentInfo)
        .setContentIntent(contentIntent)
        .setDeleteIntent(n.deleteIntent)
        .setFullScreenIntent(fullScreenIntent,
                (n.flags & Notification.FLAG_HIGH_PRIORITY) != 0)
        .setLargeIcon(largeIcon)
        .setNumber(number)
        .setUsesChronometer(useChronometer)
        .setPriority(priority)
        .setProgress(progressMax, progress, progressIndeterminate);
    mExtras = new Bundle();
    if (extras != null) {
        mExtras.putAll(extras);
    }
    if (people != null && !people.isEmpty()) {
        mExtras.putStringArray(Notification.EXTRA_PEOPLE,
                people.toArray(new String[people.size()]));
    }
    if (localOnly) {
        mExtras.putBoolean(NotificationCompatJellybean.EXTRA_LOCAL_ONLY, true);
    }
    if (groupKey != null) {
        mExtras.putString(NotificationCompatJellybean.EXTRA_GROUP_KEY, groupKey);
        if (groupSummary) {
            mExtras.putBoolean(NotificationCompatJellybean.EXTRA_GROUP_SUMMARY, true);
        } else {
            mExtras.putBoolean(NotificationCompatJellybean.EXTRA_USE_SIDE_CHANNEL, true);
        }
    }
    if (sortKey != null) {
        mExtras.putString(NotificationCompatJellybean.EXTRA_SORT_KEY, sortKey);
    }
}
 
Example 14
Source File: NotificationCompatJellybean.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
public Builder(Context context, Notification n,
        CharSequence contentTitle, CharSequence contentText, CharSequence contentInfo,
        RemoteViews tickerView, int number,
        PendingIntent contentIntent, PendingIntent fullScreenIntent, Bitmap largeIcon,
        int progressMax, int progress, boolean progressIndeterminate,
        boolean useChronometer, int priority, CharSequence subText, boolean localOnly,
        Bundle extras, String groupKey, boolean groupSummary, String sortKey) {
    b = new Notification.Builder(context)
        .setWhen(n.when)
        .setSmallIcon(n.icon, n.iconLevel)
        .setContent(n.contentView)
        .setTicker(n.tickerText, tickerView)
        .setSound(n.sound, n.audioStreamType)
        .setVibrate(n.vibrate)
        .setLights(n.ledARGB, n.ledOnMS, n.ledOffMS)
        .setOngoing((n.flags & Notification.FLAG_ONGOING_EVENT) != 0)
        .setOnlyAlertOnce((n.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0)
        .setAutoCancel((n.flags & Notification.FLAG_AUTO_CANCEL) != 0)
        .setDefaults(n.defaults)
        .setContentTitle(contentTitle)
        .setContentText(contentText)
        .setSubText(subText)
        .setContentInfo(contentInfo)
        .setContentIntent(contentIntent)
        .setDeleteIntent(n.deleteIntent)
        .setFullScreenIntent(fullScreenIntent,
                (n.flags & Notification.FLAG_HIGH_PRIORITY) != 0)
        .setLargeIcon(largeIcon)
        .setNumber(number)
        .setUsesChronometer(useChronometer)
        .setPriority(priority)
        .setProgress(progressMax, progress, progressIndeterminate);
    mExtras = new Bundle();
    if (extras != null) {
        mExtras.putAll(extras);
    }
    if (localOnly) {
        mExtras.putBoolean(EXTRA_LOCAL_ONLY, true);
    }
    if (groupKey != null) {
        mExtras.putString(EXTRA_GROUP_KEY, groupKey);
        if (groupSummary) {
            mExtras.putBoolean(EXTRA_GROUP_SUMMARY, true);
        } else {
            mExtras.putBoolean(EXTRA_USE_SIDE_CHANNEL, true);
        }
    }
    if (sortKey != null) {
        mExtras.putString(EXTRA_SORT_KEY, sortKey);
    }
}
 
Example 15
Source File: CertificateInstallActivity.java    From NetBare with MIT License 4 votes vote down vote up
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putAll(getIntent().getExtras());
}
 
Example 16
Source File: ConstantData.java    From PictureSelector with Apache License 2.0 4 votes vote down vote up
public static Bundle toEditBundle(Bundle baseBundle, FileEntity item) {
    Bundle bundle = new Bundle();
    bundle.putAll(baseBundle);
    bundle.putParcelable(KEY_CURR_ITEM, item);
    return bundle;
}
 
Example 17
Source File: TaskerPlugin.java    From MaxLock with GNU General Public License v3.0 1 votes vote down vote up
/**
 * Specify a bundle of data (probably representing whatever change happened in the condition)
 * which will be included in the QUERY_CONDITION broadcast sent by the host for each
 * event instance of the plugin.
 * <p>
 * The minimal purpose is to enable the plugin to associate a QUERY_CONDITION to the
 * with the REQUEST_QUERY that caused it.
 * <p>
 * Note that for security reasons it is advisable to also store a message ID with the bundle
 * which can be compared to known IDs on receipt. The host cannot validate the source of
 * REQUEST_QUERY intents so fake data may be passed. Replay attacks are also possible.
 * addPassThroughMesssageID() can be used to add an ID if the plugin doesn't wish to add it's
 * own ID to the pass through bundle.
 * <p>
 * Note also that there are several situations where REQUEST_QUERY will not result in a
 * QUERY_CONDITION intent (e.g. event throttling by the host), so plugin-local data
 * indexed with a message ID needs to be timestamped and eventually timed-out.
 * <p>
 * This function can be called multiple times, each time all keys in data will be added to
 * that of previous calls.
 *
 * @param requestQueryIntent intent being sent to the host
 * @param data               the data to be passed-through
 * @see #hostSupportsRequestQueryDataPassThrough(Bundle)
 * @see #retrievePassThroughData(Intent)
 * @see #addPassThroughMessageID
 */
public static void addPassThroughData(Intent requestQueryIntent, Bundle data) {

    Bundle passThroughBundle = retrieveOrCreatePassThroughBundle(requestQueryIntent);

    passThroughBundle.putAll(data);
}
 
Example 18
Source File: TaskerPlugin.java    From sony-headphones-control with GNU General Public License v3.0 1 votes vote down vote up
/**
 * Specify a bundle of data (probably representing whatever change happened in the condition)
 * which will be included in the QUERY_CONDITION broadcast sent by the host for each
 * event instance of the plugin.
 *
 * The minimal purpose is to enable the plugin to associate a QUERY_CONDITION to the
 * with the REQUEST_QUERY that caused it.
 *
 * Note that for security reasons it is advisable to also store a message ID with the bundle
 * which can be compared to known IDs on receipt. The host cannot validate the source of
 * REQUEST_QUERY intents so fake data may be passed. Replay attacks are also possible.
 * addPassThroughMesssageID() can be used to add an ID if the plugin doesn't wish to add it's
 * own ID to the pass through bundle.
 *
 * Note also that there are several situations where REQUEST_QUERY will not result in a
 * QUERY_CONDITION intent (e.g. event throttling by the host), so plugin-local data
 * indexed with a message ID needs to be timestamped and eventually timed-out.
 *
 * This function can be called multiple times, each time all keys in data will be added to
 * that of previous calls.
 *
 * @param requestQueryIntent intent being sent to the host
 * @param data the data to be passed-through
 * @see #hostSupportsRequestQueryDataPassThrough(Bundle)
 * @see #retrievePassThroughData(Intent)
 * @see #addPassThroughMessageID
 *
 */
public static void addPassThroughData( Intent requestQueryIntent, Bundle data ) {

    Bundle passThroughBundle = retrieveOrCreatePassThroughBundle( requestQueryIntent );

    passThroughBundle.putAll( data );
}
 
Example 19
Source File: TaskerPlugin.java    From xDrip with GNU General Public License v3.0 1 votes vote down vote up
/**
 * Specify a bundle of data (probably representing whatever change happened in the condition)
 * which will be included in the QUERY_CONDITION broadcast sent by the host for each
 * event instance of the plugin.
 * 
 * The minimal purpose is to enable the plugin to associate a QUERY_CONDITION to the
 * with the REQUEST_QUERY that caused it.
 * 
 * Note that for security reasons it is advisable to also store a message ID with the bundle
 * which can be compared to known IDs on receipt. The host cannot validate the source of
 * REQUEST_QUERY intents so fake data may be passed. Replay attacks are also possible.
 * addPassThroughMesssageID() can be used to add an ID if the plugin doesn't wish to add it's
 * own ID to the pass through bundle.
 * 
 * Note also that there are several situations where REQUEST_QUERY will not result in a
 * QUERY_CONDITION intent (e.g. event throttling by the host), so plugin-local data
 * indexed with a message ID needs to be timestamped and eventually timed-out.
 * 
 * This function can be called multiple times, each time all keys in data will be added to
 * that of previous calls.
 * 
 * @param requestQueryIntent intent being sent to the host
 * @param data the data to be passed-through
 * @see #hostSupportsRequestQueryDataPassThrough(Bundle)
 * @see #retrievePassThroughData(Intent)
 * @see #addPassThroughMessageID
 * 
*/
public static void addPassThroughData( Intent requestQueryIntent, Bundle data ) {
	
	Bundle passThroughBundle = retrieveOrCreatePassThroughBundle(requestQueryIntent);
	
	passThroughBundle.putAll( data );
}
 
Example 20
Source File: TaskerPlugin.java    From PowerSwitch_Android with GNU General Public License v3.0 1 votes vote down vote up
/**
 * Specify a bundle of data (probably representing whatever change happened in the condition)
 * which will be included in the QUERY_CONDITION broadcast sent by the localHost for each
 * event instance of the plugin.
 * <p/>
 * The minimal purpose is to enable the plugin to associate a QUERY_CONDITION to the
 * with the REQUEST_QUERY that caused it.
 * <p/>
 * Note that for security reasons it is advisable to also store a message ID with the bundle
 * which can be compared to known IDs on receipt. The localHost cannot validate the source of
 * REQUEST_QUERY intents so fake data may be passed. Replay attacks are also possible.
 * addPassThroughMesssageID() can be used to add an ID if the plugin doesn't wish to add it's
 * own ID to the pass through bundle.
 * <p/>
 * Note also that there are several situations where REQUEST_QUERY will not result in a
 * QUERY_CONDITION intent (e.g. event throttling by the localHost), so plugin-local data
 * indexed with a message ID needs to be timestamped and eventually timed-out.
 * <p/>
 * This function can be called multiple times, each time all keys in data will be added to
 * that of previous calls.
 *
 * @param requestQueryIntent intent being sent to the localHost
 * @param data               the data to be passed-through
 * @see #hostSupportsRequestQueryDataPassThrough(Bundle)
 * @see #retrievePassThroughData(Intent)
 * @see #addPassThroughMessageID
 */
public static void addPassThroughData(Intent requestQueryIntent, Bundle data) {

    Bundle passThroughBundle = retrieveOrCreatePassThroughBundle(requestQueryIntent);

    passThroughBundle.putAll(data);
}