【问题标题】:How to show pop up dialog in any activity android如何在任何活动android中显示弹出对话框
【发布时间】:2015-03-18 08:25:38
【问题描述】:

我正在开发一个 android 应用程序,我想在收到通知时显示弹出对话框,例如我现在正在这样做

Intent i = new Intent(context, Incomingcall.class);

         i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         startActivity(i);

它很好用,但我想在弹出对话框中使用这个功能,我怎样才能完成我的任务?有什么帮助吗?

谢谢

【问题讨论】:

    标签: android android-intent dialog popup


    【解决方案1】:

    onCreate 之外创建一个新方法并在内部使用AlertDialog 打开对话框。并在您要打开对话框的地方调用该方法。

       public void openAlert(){
        new AlertDialog.Builder(this)
                .setTitle("Really Exit?")
                .setMessage("Are you sure you want to exit?")
                .setNegativeButton(android.R.string.no, /*paste code what you want to do*/)
                .setPositiveButton(android.R.string.yes,
                        /*paste code what you want to do*/).create().show();
    }
    

    【讨论】:

      猜你喜欢
      • 2011-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多