开发者

Shown an alert from a non activity

In my app there is a polling task which calls a web service periodically. According to the response of this webservice I need to display an alert dialog with two buttons.

But I'm not able to display the dialog as an alert dialog can be showned only from an activity. Only toasts are able to display. Is there any methods to display the aler开发者_开发百科ts?


Showing Alerts from a background process is not a desired functionality.

I would suggest you to display a Notification in the Notification bar.

You can start an Activity from your Background Task with

Intent myIntent = new Intent(getApplicationContext(), MyActivityNameGoesHere.class)
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(myIntent)

In this activity you can start a regular dialog.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜