What is an Android window?

What is Window in Android?

I thought the highest level in Android is called Activity , which is the screen you see.

Can someone tell me what Window is on Android? we just have one or more of them.

+50
android android-activity
Feb 26 '12 at 8:52
source share
4 answers

Activity is what you would call a window.

Technically speaking, Activity creates a window for you.

You can have many of them, but usually not in sync. To request additional information, you can invoke a dialog or run Intent for another action.

For more information, visit this link .

+9
Feb 26 2018-12-12T00:
source share

[UPDATE] (let me share what I learned about Window after the original answer)

In one sentence, A Window is a rectangular region that has one hierarchy of views . The colored rectangles at the bottom of the image are windows.

enter image description here

As you can see, there can be several windows on one screen, and WindowManager manages them. The list of windows on the current screen can be obtained using the Hierarchy Viewer or adb shell dumpsys window .

The list of windows in the hierarchy view example: enter image description here

(Below is the original answer)




I had the same question, and I hope this can help you guys.

According to the Android Developer Documentation ,

"Each action is provided with a window in which you can draw your user interface.

and Dianne Hackborn , who is an engineer for the Android framework, gave some definitions here . She said:

A window is basically like a window on the desktop. It has one Surface , which displays the contents of the window. The application interacts with Window Manager to create windows; Window Manager creates a surface for each window and passes it to the drawing application. An application can draw whatever it wants in Surface; for Window Manager, it's just an opaque rectangle.

A surface is an object that contains pixels that are arranged on the screen . Each window that you see on the screen (dialog, full-screen activity, status bar) has its own surface that it accesses, and Surface Flinger displays them on the final display in their correct Z-order. A surface usually has more than one buffer (usually two) for double-buffering rendering: an application can draw its next UI state, while a surface flinger composes the screen using the last buffer, without waiting for the application to complete drawing.

A is an interactive user interface element inside a window. The window has a separate hierarchy of views , which provides all the behavior of the window. Whenever a window needs to be redrawn (for example, since the view itself is not valid), this is done in the Surface window . The surface is locked, which returns a canvas that can be used for painting. Draws are traversed hierarchically, passing the canvas down for each view to draw part of the user interface. After that, the surface will be unlocked and sent so that the buffer just drawn is replaced in the foreground and then arranged on the screen using a surface Flinger.

In addition, I found other information from Romain Guy 's presentation (you can watch his conversation in the Android user group in San Francisco from here and download the full slides from here )

enter image description here

So, in a nutshell:

  • There is a window in Activity (in which it draws its user interface),
  • a Window has a single Surface and one view hierarchy attached to it,
  • a Surface includes a ViewGroup that contains views.
+131
May 07 '13 at 9:54 am
source share

Android: window, surface, canvas and bitmap Here is a simple and simple conceptual overview of how interaction occurs between a window, a surface, a canvas, and a bitmap.

+9
Jul 21 '16 at 6:49
source share

I would like to say briefly:

 Application ---> Activity ---> Window Manager ---> Window ---> Surface ---> Canvas ---> View Root ---> View Group ---> View ---> Bitmap/Open GL panel ---> Current Surface Buffer ---> Surface Flinger ---> Screen 
+1
Nov 15 '17 at 5:18
source share



All Articles