本文整理匯總了Java中android.os.Bundle.clear方法的典型用法代碼示例。如果您正苦於以下問題:Java Bundle.clear方法的具體用法?Java Bundle.clear怎麽用?Java Bundle.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.os.Bundle
的用法示例。
在下文中一共展示了Bundle.clear方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isSuspicious
import android.os.Bundle; //導入方法依賴的package包/類
/**
* 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;
}
示例2: scrub
import android.os.Bundle; //導入方法依賴的package包/類
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;
}
示例3: clearBundle
import android.os.Bundle; //導入方法依賴的package包/類
private void clearBundle(Bundle safeBundle) {
safeBundle.clear();
safeBundle = null;
}
示例4: onSaveInstanceState
import android.os.Bundle; //導入方法依賴的package包/類
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.clear();
}