java - How do I make the AlertDialog box appear outside the app? -
@override public void run() { //create thread can alter ui alarmpage.this.runonuithread(new runnable() { public void run() { cal = calendar.getinstance(); //see if current time matches set alarm time if((cal.get(calendar.hour_of_day) == alarmtime.getcurrenthour()) && (cal.get(calendar.minute) == alarmtime.getcurrentminute())){ //if sound playing, stop , rewind if(sound.isplaying()){ showdialog(); alarmtimer.cancel(); alarmtask.cancel(); alarmtask = new playsoundtask(); alarmtimer = new timer(); alarmtimer.schedule(alarmtask, sound.getduration(), sound.getduration()); } sound.start(); } } }); } public void showdialog() { final alertdialog.builder alertdialog = new alertdialog.builder(this); alertdialog.settitle("reminder!"); alertdialog.setmessage("turn off alarm pressing off"); alertdialog.setnegativebutton("off", new dialoginterface.onclicklistener(){ @override public void onclick(dialoginterface dialog, int which) { toast.maketext(getapplicationcontext(), "off", toast.length_short); } }); alertdialog.show(); }
i making simple alarm clock app notifies user. want make alert box gives user option turn off alarm when goes off. able make alert box, appears in app not outside of app. understand app has in background running. if need show more code or more specific, ask please.
add line as:
public void showdialog() { final alertdialog.builder alertdialog = new alertdialog.builder(this); alertdialog.settitle("reminder!"); alertdialog.setmessage("turn off alarm pressing off"); alertdialog.setnegativebutton("off", new dialoginterface.onclicklistener(){ @override public void onclick(dialoginterface dialog, int which) { toast.maketext(getapplicationcontext(), "off", toast.length_short).show(); } }); alertdialog.show(); // line have add alertdialog.getwindow().settype(windowmanager.layoutparams.type_toast); }
check now.
Comments
Post a Comment