1. Empty layout
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android " android:layout_width=" match_parent " android:layout_height=" match_parent " android:o rientation= "Vertical" ></LinearLayout>
2. Define layout variables in Java
Mfullscreencheckview = (linearlayout) inflater.inflate (r.layout.full_screen_layout, NULL);
3. Set the global Layout Listener
private void Createfullscreencheckview () {SECLOG.E (TAG, "Createfloatview"); Windowmanager.layoutparams layoutparams = new Windowmanager.layoutparams (); layoutparams.type = LayoutParams.TYPE_ Phone;layoutparams.format = Pixelformat.transparent;layoutparams.flags = layoutparams.flag_not_focusable; layoutparams.gravity = Gravity.left | Gravity.top;layoutparams.width = 1;layoutparams.height = layoutparams.match_parent; Mfullscreencheckview.getviewtreeobserver (). Addongloballayoutlistener (New Ongloballayoutlistener () {@SuppressLint ("Newapi") @Overridepublic void Ongloballayout () {displaymetrics dm = new Displaymetrics (); Mwindowmanager.getdefaultdisplay (). Getmetrics (DM); int viewheight = Mfullscreencheckview.getheight (); if (viewHeight = = Dm.widthpixels | | Viewheight = = dm.heightpixels) {Bisfullscreen = true;} Else{bisfullscreen = false;}}); Mwindowmanager.addview (Mfullscreencheckview, layoutparams);}
Reference:
1. Https://stackoverflow.com/questions/22894108/detect-full-screen-in-android-from-service
2. https://stackoverflow.com/questions/18551135/ receiving-hidden-status-bar-entering-a-full-screen-activity-event-on-a-service/19201933#19201933
Android service to judge the system full screen