Context.IsUiContext 屬性

定義

true如果內容是可以存取 、 android.view.LayoutInflater LayoutInflaterandroid.app.WallpaperManager WallpaperManagerWindowManager UI 元件的 UI 內容,則傳回 。

public virtual bool IsUiContext { [Android.Runtime.Register("isUiContext", "()Z", "GetIsUiContextHandler", ApiSince=31)] get; }
[<get: Android.Runtime.Register("isUiContext", "()Z", "GetIsUiContextHandler", ApiSince=31)>]
member this.IsUiContext : bool

屬性值

屬性

備註

true如果內容是可以存取 、 android.view.LayoutInflater LayoutInflaterandroid.app.WallpaperManager WallpaperManagerWindowManager UI 元件的 UI 內容,則傳回 。 如果 android.os.StrictMode.VmPolicy.Builder#detectIncorrectContextUse() 已啟用,則從非 UI 內容存取 UI 元件會 android.os.strictmode.Violation 擲回。

UI 內容的範例包括 、 android.app.Activity Activity#createWindowContext(int, Bundle) 或 建立的內容 android.inputmethodservice.InputMethodService InputMethodService

請注意,即使以程式設計方式允許,也不建議覆寫此方法以略過 android.os.strictmode.IncorrectContextUseViolation 驗證。

android.content.Context.isUiContext() JAVA 檔。

此頁面的部分是根據所建立和共用的工作進行修改,並根據 2.5 屬性授權中所述的詞彙來使用。

適用於