本文整理汇总了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();
}