开发者

Why can't I use the Context of a Service to display an AlertDialog

Why can't I use the Context of a Service to display an AlertDialog ?

I can do it w开发者_高级运维ith Toast!


It may not be as implicit as Toast.makeText() but in the constructor for AlertDialog.Builder it takes in a Context as a parameter.

// creates an AlertDialog to the instance of the Context
alertDialog = new AlertDialog.Builder(this).create(); 
alertDialog.setTitle("Alert 1");
alertDialog.setMessage("This is an alert");
// display your dialog with an OK button.
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int which) {
    return;
  } }); 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜