gpt4 book ai didi

android - Android 中 "restricted context"的示例是什么?

转载 作者:行者123 更新时间:2023-11-29 23:11:02 31 4
gpt4 key购买 nike

Context 类有一个方法isRestricted,根据文档,它是

Indicates whether this Context is restricted.

此方法在Context 类中默认返回false

public boolean isRestricted() {
return false;
}

我无法找到任何实际上具有受限上下文的 Context 子类的示例。举几个例子,具体有什么作用?

最佳答案

有关标志 CONTEXT_RESTRICTED 的文档中提供了更多信息 -- https://developer.android.com/reference/android/content/Context.html#CONTEXT_RESTRICTED

Flag for use with createPackageContext(String, int): a restricted context may disable specific features. For instance, a View associated with a restricted context would ignore particular XML attributes.

因此,似乎只有通过 createPackageContext() 创建并传递此标志的 Context 才会从 isRestricted( )

关于android - Android 中 "restricted context"的示例是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56021968/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com