Service Inside Popup dialog box

Source: Internet
Author: User
How to pop up a dialog box inside a service
First give a demand: need to listen to the service inside the receiving text message, if received a text message, pop up a dialog to prompt the user to open.

See: (POPs up directly on the main desktop)



The service pop-up prompt box:
Alertdialog.builder Alertdialog = new Alertdialog.builder (this); Alertdialog.setmessage ("Is there a new message, are you viewing?") "); Alertdialog.setpositivebutton (" No ", new Dialoginterface.onclicklistener () {public void OnClick (dialoginterface dialog, int which) {}}); Alertdialog.setnegativebutton ("Yes", new Dialoginterface.onclicklistener () {public void OnClick ( Dialoginterface dialog, int which) {}}); ad = Alertdialog.create ();        Ad.getwindow (). SetType (WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);          Ad.setcanceledontouchoutside (false);//Click outside the area will not let dialog disappear                                       ad.show ();


Don't forget to add permissions on the manifest:
<uses-permission android:name= "Android.permission.SYSTEM_ALERT_WINDOW"/>

Service Inside Popup dialog box

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.