Java Code Examples for android.os.bundle#getBundle()

The following examples show how to use android.os.bundle#getBundle() . 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: PreferenceFragment.java    From android-support-v4-preferencefragment with Apache License 2.0 6 votes vote down vote up
@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);
            }
        }
    }
}
 
Example 2
Source File: PreferenceFragmentCompat.java    From ticdesign with Apache License 2.0 6 votes vote down vote up
@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);
            }
        }
    }
}
 
Example 3
Source File: ActivityHostProxy.java    From Phantom with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 4
Source File: AppLinkData.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
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;
}
 
Example 5
Source File: NotificationCompat.java    From letv with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 6
Source File: NavigatorLifecycleDelegate.java    From Mortar-architect with MIT License 6 votes vote down vote up
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();
}
 
Example 7
Source File: UsageStats.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 8
Source File: NativeProtocol.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 9
Source File: AppLinks.java    From Bolts-Android with MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example 10
Source File: NativeProtocol.java    From letv with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 11
Source File: CaldroidFragment.java    From iSCAU-Android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
	}
}
 
Example 12
Source File: LoginActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@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);
    }
}
 
Example 13
Source File: SipService.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
@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);
        }
    });
}
 
Example 14
Source File: NativeProtocol.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 15
Source File: ImageCropper.java    From ImageFileSelector with Apache License 2.0 5 votes vote down vote up
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");
        }
    }
}
 
Example 16
Source File: Step.java    From material-singleinputform with MIT License 5 votes vote down vote up
public void restore(Bundle setupData){
	if(setupData != null){
		Bundle data = setupData.getBundle(key);
		if(data != null){
			this.data = data;
		}
	}
	onRestore();
}
 
Example 17
Source File: ActivityRequestState.java    From Pioneer with Apache License 2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example 18
Source File: ReactiveBillingShadowActivity.java    From Reactive-Billing with MIT License 4 votes vote down vote up
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    extras = savedInstanceState.getBundle("BUY_EXTRAS");
    super.onRestoreInstanceState(savedInstanceState);
}
 
Example 19
Source File: CordovaInterfaceImpl.java    From cordova-plugin-app-update-demo with MIT License 4 votes vote down vote up
/**
 * 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;
}
 
Example 20
Source File: CordovaInterfaceImpl.java    From pychat with MIT License 4 votes vote down vote up
/**
 * 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;
}