下面列出了android.os.Bundle#getBundle ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (mHavePrefs) {
bindPreferences();
}
mInitDone = true;
if (savedInstanceState != null) {
Bundle container = savedInstanceState.getBundle(PREFERENCES_TAG);
if (container != null) {
final PreferenceScreen preferenceScreen = getPreferenceScreen();
if (preferenceScreen != null) {
preferenceScreen.restoreHierarchyState(container);
}
}
}
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
savedInstanceState.setClassLoader(mPluginInfo.getPluginClassLoader());
Set<String> keys = savedInstanceState.keySet();
for (String key : keys) {
Bundle internalBundle = savedInstanceState.getBundle(key);
if (null != internalBundle) {
internalBundle.setClassLoader(mPluginInfo.getPluginClassLoader());
}
}
try {
super.onRestoreInstanceState(savedInstanceState);
} catch (Exception e) {
VLog.w(e, "super.onRestoreInstanceState() error");
LogReporter.reportException(e);
}
Bundle savedData = getPluginSavedData(savedInstanceState);
callTargetActivityMethod(ON_RESTORE_INSTANCE_STATE, "onRestoreInstanceState", savedData);
}
private static AppLinkData createFromAlApplinkData(Intent intent) {
Bundle applinks = intent.getBundleExtra(BUNDLE_AL_APPLINK_DATA_KEY);
if (applinks == null) {
return null;
}
AppLinkData appLinkData = new AppLinkData();
appLinkData.targetUri = intent.getData();
if (appLinkData.targetUri == null) {
String targetUriString = applinks.getString(METHOD_ARGS_TARGET_URL_KEY);
if (targetUriString != null) {
appLinkData.targetUri = Uri.parse(targetUriString);
}
}
appLinkData.argumentBundle = applinks;
appLinkData.arguments = null;
Bundle refererData = applinks.getBundle(ARGUMENTS_REFERER_DATA_KEY);
if (refererData != null) {
appLinkData.ref = refererData.getString(REFERER_DATA_REF_KEY);
}
return appLinkData;
}
public void onCreate(Intent intent, Bundle savedInstanceState, NavigatorView containerView, StackablePath... defaultPaths) {
Preconditions.checkNotNull(containerView, "Container view cannot not be null");
Preconditions.checkArgument(defaultPaths != null && defaultPaths.length > 0, "Default path cannot not be null nor empty");
if (navigator.history.shouldInit()) {
Bundle bundle = null;
if (!navigator.config.dontRestoreStackAfterKill) {
if (intent != null && intent.hasExtra(HISTORY_KEY)) {
bundle = intent.getBundleExtra(HISTORY_KEY);
} else if (savedInstanceState != null && savedInstanceState.containsKey(HISTORY_KEY)) {
bundle = savedInstanceState.getBundle(HISTORY_KEY);
}
}
if (bundle != null) {
navigator.history.init(bundle);
} else {
navigator.history.init(defaultPaths);
}
}
navigator.presenter.attach(containerView);
navigator.dispatcher.activate();
}
public WearableExtender(Notification notif) {
Bundle extras = NotificationCompat.getExtras(notif);
Bundle wearableBundle = extras != null ? extras.getBundle(EXTRA_WEARABLE_EXTENSIONS) : null;
if (wearableBundle != null) {
Action[] actions = NotificationCompat.IMPL.getActionsFromParcelableArrayList(wearableBundle.getParcelableArrayList(KEY_ACTIONS));
if (actions != null) {
Collections.addAll(this.mActions, actions);
}
this.mFlags = wearableBundle.getInt(KEY_FLAGS, 1);
this.mDisplayIntent = (PendingIntent) wearableBundle.getParcelable(KEY_DISPLAY_INTENT);
Notification[] pages = NotificationCompat.getNotificationArrayFromBundle(wearableBundle, KEY_PAGES);
if (pages != null) {
Collections.addAll(this.mPages, pages);
}
this.mBackground = (Bitmap) wearableBundle.getParcelable(KEY_BACKGROUND);
this.mContentIcon = wearableBundle.getInt(KEY_CONTENT_ICON);
this.mContentIconGravity = wearableBundle.getInt(KEY_CONTENT_ICON_GRAVITY, 8388613);
this.mContentActionIndex = wearableBundle.getInt(KEY_CONTENT_ACTION_INDEX, -1);
this.mCustomSizePreset = wearableBundle.getInt(KEY_CUSTOM_SIZE_PRESET, 0);
this.mCustomContentHeight = wearableBundle.getInt(KEY_CUSTOM_CONTENT_HEIGHT);
this.mGravity = wearableBundle.getInt(KEY_GRAVITY, 80);
this.mHintScreenTimeout = wearableBundle.getInt(KEY_HINT_SCREEN_TIMEOUT);
}
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (mHavePrefs) {
bindPreferences();
}
mInitDone = true;
if (savedInstanceState != null) {
Bundle container = savedInstanceState.getBundle(PREFERENCES_TAG);
if (container != null) {
final PreferenceScreen preferenceScreen = getPreferenceScreen();
if (preferenceScreen != null) {
preferenceScreen.restoreHierarchyState(container);
}
}
}
}
@Override
public void onReceive(Context context, final Intent intent) {
final Bundle extras = intent.getExtras();
final String action = intent.getAction();
if(extras == null) {
Log.e(THIS_FILE, "No data in intent retrieved for call");
return;
}
if(!SipManager.ACTION_SIP_CALL_LAUNCH.equals(action)) {
Log.e(THIS_FILE, "Received invalid action " + action);
return;
}
final int accountId = extras.getInt(SipProfile.FIELD_ID, -2);
final String callee = extras.getString(SipManager.EXTRA_SIP_CALL_TARGET);
final Bundle options = extras.getBundle(SipManager.EXTRA_SIP_CALL_OPTIONS);
if(accountId == -2 || callee == null) {
Log.e(THIS_FILE, "Invalid rewrite " + accountId);
return;
}
getExecutor().execute(new SipRunnable() {
@Override
protected void doRun() throws SameThreadException {
pjService.makeCall(callee, accountId, options);
}
});
}
public void onLoad(Bundle savedInstanceState) {
if (savedInstanceState != null) {
Bundle bundle = savedInstanceState.getBundle(SAVED_ACTIVITY_REQUEST_STATE);
if (bundle != null) {
requestIntent = bundle.getParcelable(KEY_REQUEST_INTENT);
requestArgs = bundle.getBundle(KEY_REQUEST_ARGS);
requestCode = bundle.getInt(KEY_REQUEST_CODE, -1);
}
}
}
public void restore(Bundle setupData){
if(setupData != null){
Bundle data = setupData.getBundle(key);
if(data != null){
this.data = data;
}
}
onRestore();
}
public void onRestoreInstanceState(Bundle savedInstanceState) {
if (savedInstanceState != null && savedInstanceState.containsKey(IMAGE_CROPPER_BUNDLE)) {
Bundle bundle = savedInstanceState.getBundle(IMAGE_CROPPER_BUNDLE);
if (bundle != null) {
mOutPutX = bundle.getInt("outputX");
mOutPutY = bundle.getInt("outputY");
mAspectX = bundle.getInt("aspectX");
mAspectY = bundle.getInt("aspectY");
mScale = bundle.getBoolean("scale");
mOutFile = (File) bundle.getSerializable("outFile");
mSrcFile = (File) bundle.getSerializable("srcFile");
mTempFile = (File) bundle.getSerializable("tempFile");
}
}
}
public static Bundle getSuccessResultsFromIntent(Intent resultIntent) {
int version = getProtocolVersionFromIntent(resultIntent);
Bundle extras = resultIntent.getExtras();
if (!isVersionCompatibleWithBucketedIntent(version) || extras == null) {
return extras;
}
return extras.getBundle(EXTRA_PROTOCOL_METHOD_RESULTS);
}
@Override
public UsageStats createFromParcel(Parcel in) {
UsageStats stats = new UsageStats();
stats.mPackageName = in.readString();
stats.mBeginTimeStamp = in.readLong();
stats.mEndTimeStamp = in.readLong();
stats.mLastTimeUsed = in.readLong();
stats.mTotalTimeInForeground = in.readLong();
stats.mLaunchCount = in.readInt();
stats.mAppLaunchCount = in.readInt();
stats.mLastEvent = in.readInt();
Bundle allCounts = in.readBundle();
if (allCounts != null) {
stats.mChooserCounts = new ArrayMap<>();
for (String action : allCounts.keySet()) {
if (!stats.mChooserCounts.containsKey(action)) {
ArrayMap<String, Integer> newCounts = new ArrayMap<>();
stats.mChooserCounts.put(action, newCounts);
}
Bundle currentCounts = allCounts.getBundle(action);
if (currentCounts != null) {
for (String key : currentCounts.keySet()) {
int value = currentCounts.getInt(key);
if (value > 0) {
stats.mChooserCounts.get(action).put(key, value);
}
}
}
}
}
return stats;
}
@Override
public void restoreStateParams(Bundle bundle)
{
currentParams = bundle.getBundle("passview_params");
if (currentParams != null)
{
setParams(currentParams, true);
}
String code = bundle.getString("passview_code");
if (code != null)
{
codeField.setText(code);
}
}
/**
* Restore current states from savedInstanceState
*
* @param savedInstanceState
* @param key
*/
public void restoreStatesFromKey(Bundle savedInstanceState, String key) {
if (savedInstanceState != null && savedInstanceState.containsKey(key)) {
Bundle caldroidSavedState = savedInstanceState.getBundle(key);
setArguments(caldroidSavedState);
}
}
public static Bundle getErrorDataFromResultIntent(Intent resultIntent) {
if (!isErrorResult(resultIntent)) {
return null;
}
Bundle bridgeArgs = getBridgeArgumentsFromIntent(resultIntent);
if (bridgeArgs != null) {
return bridgeArgs.getBundle(BRIDGE_ARG_ERROR_BUNDLE);
}
return resultIntent.getExtras();
}
/**
* Gets the App Link extras for an intent, if there is any.
*
* @param intent the incoming intent.
* @return a bundle containing the App Link extras for the intent, or {@code null} if none is
* specified.
*/
public static Bundle getAppLinkExtras(Intent intent) {
Bundle appLinkData = getAppLinkData(intent);
if (appLinkData == null) {
return null;
}
return appLinkData.getBundle(KEY_NAME_EXTRAS);
}
public static Bundle getSuccessResultsFromIntent(Intent resultIntent) {
int version = getProtocolVersionFromIntent(resultIntent);
Bundle extras = resultIntent.getExtras();
if (!isVersionCompatibleWithBucketedIntent(version) || extras == null) {
return extras;
}
return extras.getBundle(EXTRA_PROTOCOL_METHOD_RESULTS);
}
/**
* Call this from onCreate() so that any saved startActivityForResult parameters will be restored.
*/
public void restoreInstanceState(Bundle savedInstanceState) {
initCallbackService = savedInstanceState.getString("callbackService");
savedPluginState = savedInstanceState.getBundle("plugin");
activityWasDestroyed = true;
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
extras = savedInstanceState.getBundle("BUY_EXTRAS");
super.onRestoreInstanceState(savedInstanceState);
}
/**
* Call this from onCreate() so that any saved startActivityForResult parameters will be restored.
*/
public void restoreInstanceState(Bundle savedInstanceState) {
initCallbackService = savedInstanceState.getString("callbackService");
savedPluginState = savedInstanceState.getBundle("plugin");
activityWasDestroyed = true;
}