Java Code Examples for android.os.Bundle.clear()

The following are Jave code examples for showing how to use clear() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Saiy-PS   File: UtilsBundle.java   View Source Code Vote up 6 votes
/**
 * Scrubs Bundles for private serializable subclasses in the extras. If the Bundle's extras contain a
 * private serializable subclass, the Bundle is cleared. If the Bundle is null, has no extras, or the
 * extras do not contain a private serializable subclass, the Bundle is not mutated.
 *
 * @param bundle {@code Bundle} to scrub. This parameter may be mutated if scrubbing is necessary. This
 *               parameter may be null.
 * @return true if the Bundle was scrubbed, false if the Bundle was not modified.
 */
public static boolean isSuspicious(@Nullable final Bundle bundle) {

    if (bundle != null) {

    /*
     * Note: This is a hack to work around a private serializable classloader attack
     */
        try {
            // if a private serializable exists, this will throw an exception
            bundle.containsKey(null);
        } catch (final Exception e) {
            bundle.clear();
            return true;
        }
    }

    return false;
}
 
Example 2
Project: CustomAndroidOneSheeld   File: BundleScrubber.java   View Source Code Vote up 5 votes
public static boolean scrub(final Bundle bundle) {
    if (null == bundle) {
        return false;
    }
    try {
        // if a private serializable exists, this will throw an exception
        bundle.containsKey(null);
    } catch (final Exception e) {
        bundle.clear();
        return true;
    }

    return false;
}
 
Example 3
Project: garras   File: Bundler.java   View Source Code Vote up 4 votes
private void clearBundle(Bundle safeBundle) {
    safeBundle.clear();
    safeBundle = null;
}
 
Example 4
Project: decoy   File: WelcomeActivity.java   View Source Code Vote up 4 votes
@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.clear();
}
 
Example 5
Project: decoy   File: MainActivity.java   View Source Code Vote up 4 votes
@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.clear();
}