diff options
| -rw-r--r-- | core/java/android/content/Context.java | 36 | ||||
| -rw-r--r-- | core/java/android/view/WindowManager.java | 20 | 
2 files changed, 24 insertions, 32 deletions
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 1907d18f56c5..ceba01ec62e0 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -6447,30 +6447,24 @@ public abstract class Context {              @NonNull Configuration overrideConfiguration);      /** -     * Return a new Context object for the current Context but whose resources -     * are adjusted to match the metrics of the given Display.  Each call to this method -     * returns a new instance of a Context object; Context objects are not -     * shared, however common state (ClassLoader, other Resources for the -     * same configuration) may be so the Context itself can be fairly lightweight. -     * -     * To obtain an instance of a {@link WindowManager} (see {@link #getSystemService(String)}) that -     * is configured to show windows on the given display call -     * {@link #createWindowContext(int, Bundle)} on the returned display Context or use an -     * {@link android.app.Activity}. -     * +     * Returns a new <code>Context</code> object from the current context but with resources +     * adjusted to match the metrics of <code>display</code>. Each call to this method +     * returns a new instance of a context object. Context objects are not shared; however, +     * common state (such as the {@link ClassLoader} and other resources for the same +     * configuration) can be shared, so the <code>Context</code> itself is lightweight.       * <p> -     * Note that invoking #createDisplayContext(Display) from an UI context is not regarded -     * as an UI context. In other words, it is not suggested to access UI components (such as -     * obtain a {@link WindowManager} by {@link #getSystemService(String)}) -     * from the context created from #createDisplayContext(Display). -     * </p> -     * -     * @param display A {@link Display} object specifying the display for whose metrics the -     * Context's resources should be tailored. +     * To obtain an instance of {@link WindowManager} configured to show windows on the given +     * display, call {@link #createWindowContext(int, Bundle)} on the returned display context, +     * then call {@link #getSystemService(String)} or {@link #getSystemService(Class)} on the +     * returned window context. +     * <p> +     * <b>Note:</b> The context returned by <code>createDisplayContext(Display)</code> is not a UI +     * context. Do not access UI components or obtain a {@link WindowManager} from the context +     * created by <code>createDisplayContext(Display)</code>.       * -     * @return A {@link Context} for the display. +     * @param display The display to which the current context's resources are adjusted.       * -     * @see #getSystemService(String) +     * @return A context for the display.       */      @DisplayContext      public abstract Context createDisplayContext(@NonNull Display display); diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 55beae0f7b3d..00f4eb83bdaa 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -127,17 +127,15 @@ import java.util.function.Consumer;  /**   * The interface that apps use to talk to the window manager. - * </p><p> - * Each window manager instance is bound to a particular {@link Display}. - * To obtain a {@link WindowManager} for a different display, use - * {@link Context#createDisplayContext} to obtain a {@link Context} for that - * display, then use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> - * to get the WindowManager. - * </p><p> - * The simplest way to show a window on another display is to create a - * {@link Presentation}.  The presentation will automatically obtain a - * {@link WindowManager} and {@link Context} for that display. - * </p> + * <p> + * Each window manager instance is bound to a {@link Display}. To obtain the + * <code>WindowManager</code> associated with a display, + * call {@link Context#createWindowContext(Display, int, Bundle)} to get the display's UI context, + * then call {@link Context#getSystemService(String)} or {@link Context#getSystemService(Class)} on + * the UI context. + * <p> + * The simplest way to show a window on a particular display is to create a {@link Presentation}, + * which automatically obtains a <code>WindowManager</code> and context for the display.   */  @SystemService(Context.WINDOW_SERVICE)  public interface WindowManager extends ViewManager {  |