Android Fakewindow for small applications big use

Source: Internet
Author: User

Android Fakewindow for small applications big use


in WindowManager There is a fakewindow, a careful look is a transparent application to cover the front of the screen, so what are the advantages? First of all, we will look at this problem from the application needs. In the Android system, whether it is a mobile phone or tablet, the status bar is generally in, the navigation bar in some devices is not, because Android needs those home\back\menu\sercach may have been done on the touch screen, or some other low-cost touch small keys or hard keys, but there are very many machines are not these, then need a navigation bar, so that the early background is clear.

With the navigation bar and the status bar, good is good, especially the navigation bar occupies the screen location ah, in some need large screen or full-screen application, navigation bar and status bar is also so unsightly, for example, look at the picture, when watching the movie, generally want to be able to occupy the screen completely, so see the effect better. If you want to have a good effect, you have to have a method, of course. We know that the navigation bar and the status bar belong to the category of Systemui, to occupy their position, we have to discuss with them well, fortunately there are windowsmanager policy to coordinate. Detailed Location:

/*****************************************************************************************************/
Disclaimer: The content of this blog is by http://blog.csdn.net/edsam49 original, reproduced please indicate the source, thank you!
/*****************************************************************************************************/

Android\frameworks\base\policy\src\com\android\internal\policy\impl\phonewindowmanager.java, how to apply full-screen design very easy, The author in last year's blog post introduced, need to look at this "Systemui in the status bar and navigation bar hide display control method and effect demonstration sample " Link: http://blog.csdn.net/edsam49/article/details/11819209

when you apply for the full screen, Phonewindowsmanager will give the system to add a Fakewindow to accept the touch screen input events, not limited to touch screen ah, assuming that the key can also intercept the message. Let's see how this Fakewindow is added to the system, code such as the following:

            if (navvisible | | navallowedhidden) {if (Mhidenavfakewindow! = null) {Mhid                    Enavfakewindow.dismiss ();                Mhidenavfakewindow = null; }} else if (Mhidenavfakewindow = = null) {//Add this for Navi would show without navigation ba R when System_ui_flag_hide_navigation setted if (Mfocusedwindow! = null) {//LOG.I (TAG,                    "----> Chen Mfocusedwindow:" + Mfocusedwindow);                    Final Windowmanager.layoutparams attr = Mfocusedwindow.getattrs ();                    Final charsequence title = Attr.gettitle ();                        if (!needfullscreennonavigationbar (title)) {Mhidenavfakewindow = Mwindowmanagerfuncs.addfakewindow ( Mhandler.getlooper (), Mhidenavinputeventreceiverfactory, "Hidden nav", Windowmanag Er. Layoutparams.type_hidden_nav_consumer, 0, 0, False, False, true); }                }            }
The key or Mwindowmanagerfuncs.addfakewindow () This function to join, the detailed parameters can look at this function prototype, but also very easy, detailed in the following two files to see:

Framework/base/core/java/android/view/windowmanagerpolicy.java and Framework/base/services/java/com/android/server /wm/windowmanagerservice.java

We also know about the Fakewindow, that is, in the full screen can intercept the event input, in Phonewindowsmanager inside this Fakewindow is once received the event input message dismiss, and then eliminate, At the same time the navigation bar or something should come out. The author is in the car navigation products, we in reversing, the screen needs to display full-screen reversing video signal, this signal is covered on the top, assuming reversing when you go to press the screen, and this time assuming not intercept such event input message, in the reverse video application does not know will be treated like above, Anyway, you do not know what will be ordered, this is obviously not good, then we need to deal with reversing video of the input event to intercept, of course, some people say that I do not go to the touch screen driver reporting data, then there are keys? It is also said that this time, I do not report, suppose there is a serial protocol to come over it? and a mouse? What about the keyboard? Each to cut, each to disabled, too tired. With Fakewindow convenient very much, that is, price transparent window to intercept whatever input event, this will be convenient very much, the system overhead is not small, almost negligible.

Fakewindow is still very practical, I hope this introduction to some students practical.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.