The Dialog box appears in the Service for android, that is, the global Dialog box.

Source: Internet
Author: User
Tags what interface

First, let's talk about the specific practice. The reason is as follows:
After writing the Alter function block, add the following before the alter. show () Statement:
Alert. getWindow (). setType (WindowManager. LayoutParams. TYPE_SYSTEM_ALERT );
Note: alter is an AlertDialog type object.
Then add the permission to AndroidManifest. xml:
<Uses-permission android: name = "android. permission. SYSTEM_ALERT_WINDOW"> </uses-permission>

The following is a simple explanation:
If you only write the Alter code that is often used in the Activity in the Service, an error will occur during running, because the display of Alter needs to be attached to a definite Activity class. The above method is to declare that the prompt box we want to pop up is a system prompt box, that is, a global prompt box, so as long as the phone is in the boot status, no matter what interface it is in, you only need to call alter. show (), a prompt box will pop up.

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.