Merge "Reconciled description of WindowManager with description of Context#createDisplayContext()."

This commit is contained in:
Jon Eckenrode
2021-11-22 16:21:19 +00:00
committed by Gerrit Code Review
2 changed files with 24 additions and 32 deletions

View File

@@ -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>
* 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>.
*
* @param display A {@link Display} object specifying the display for whose metrics the
* Context's resources should be tailored.
* @param display The display to which the current context's resources are adjusted.
*
* @return A {@link Context} for the display.
*
* @see #getSystemService(String)
* @return A context for the display.
*/
@DisplayContext
public abstract Context createDisplayContext(@NonNull Display display);

View File

@@ -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 {