MIUI display of suspended windows

Source: Internet
Author: User

1. Use the hover box

<uses-permission android:name= "Android.permission.SYSTEM_ALERT_WINDOW"/>

2. Concrete implementation

Package Com.pandans.hnairexam;import Com.pandans.sunshine.provider.sunshinedb.bookt;import Android.app.application;import Android.content.context;import Android.graphics.pixelformat;import Android.util.displaymetrics;import Android.view.gravity;import Android.view.windowmanager;import Android.view.windowmanager.layoutparams;public class Examapplication extends application {private Windowmanager.layoutparams windowparams = null;public windowmanager.layoutparams getWindowParams () {if (WindowParams = = null) {Createwindowparams ();} return windowparams;} Private Windowmanager.layoutparams Createwindowparams () {windowparams = new windowmanager.layoutparams (); Windowparams.type = Windowmanager.layoutparams.type_phone;windowparams.flags = WindowManager.LayoutParams.FLAG_NOT _focusable| windowmanager.layoutparams.flag_not_touch_modal| Windowmanager.layoutparams.flag_watch_outside_touch;windowparams.format = pixelformat.translucent;/* * Note that The value of flag can be: the effect of the Flags property below is the same as "lock". The suspended window is not touch, accepts no events, and does not affect subsequent event responses。 * Layoutparams.flag_not_touch_modal does not affect subsequent events * layoutparams.flag_not_focusable non-focused layoutparams.flag_not_touchable * Non-touch *///adjust the hover window to the upper left corner for easy adjustment of coordinates windowparams.gravity = Gravity.left | gravity.top;//the upper-left corner of the screen as the origin, set X, y initial value windowparams.x = 0;windowparams.y = 0;setdisplay (windowparams); return windowparams;} /** * Drag to change position * * @param x * @param y */public void updatewindows (int x, int y) {windowparams.y = y; ((WindowManager) Getsy Stemservice (Window_service)). Updateviewlayout (Mfloatview, windowparams);} public void Setdisplay (Windowmanager.layoutparams params) {displaymetrics dm = new Displaymetrics ();((WindowManager) Getsystemservice (Window_service)). Getdefaultdisplay (). Getmetrics (DM);p arams.width = layoutparams.match_parent; Params.height = (int) (Dm.heightpixels * 0.4);//params.height = 200;} Private Pfloatview mfloatview;public void CreateView (Context cnt) {if (Mfloatview = = null) {Mfloatview = new Pfloatview (CN t); Mfloatview.setspinnerdata (CNT, Getcontentresolver (). query (Bookt.content_uri, NULL, NULL, NULL, NULL));((WindowManager) Getsystemservice (Window_service)). AddView (Mfloatview, Getwindowparams ());}} public void ClearView () {if (Mfloatview! = null) {((WindowManager) Getsystemservice (Window_service)). Removeview ( Mfloatview); mfloatview = null;}}}

  

The actual use of the process found MIUI machine can not eject the suspended window, after verification, Millet has to do a permission, the default suspension window can not pop.

Solve:

1. Find the System Application "Security Center" on the desktop

Tap to enter the app


2, click on the lower right corner of the "Authorization Management" to enter


Click on the second "Application Rights Management" to enter the detailed management interface


3, right slip into the rights management, found in the bottom of the suspension window elective, click to enter

4. Click on the icon to select Allow

MIUI display of suspended windows

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.