下面列出了android.os.Bundle#putAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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;
}
/**
* 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;
}
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);
}
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;
}
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;
}
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);
}
/**
* 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();
}
/**
* 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();
}
}
@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);
}
}
public static String toString(Bundle b) {
if (b == null) {
return "";
}
Bundle bundle = new Bundle();
bundle.putAll(b);
return bundle.toString();
}
/**
* 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();
}
}
public static Bundle toEditBundle(Bundle baseBundle, FileEntity item) {
Bundle bundle = new Bundle();
bundle.putAll(baseBundle);
bundle.putParcelable(KEY_CURR_ITEM, item);
return bundle;
}
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);
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putAll(mProperties);
}
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);
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putAll(getIntent().getExtras());
}
/**
* 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 );
}
/**
* 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);
}
/**
* 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 );
}
/**
* 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);
}