gpt4 book ai didi

android - 在不打开父 Activity 的情况下打开警报对话框 Activity

转载 作者:太空狗 更新时间:2023-10-29 14:38:30 27 4
gpt4 key购买 nike

我正在编写一个提供快速 AlertDialog 的程序。 AlertDialog 自行出现,但父 Activity 在任务中打开。该应用程序是关于接收短信的。用户第一次运行该应用程序并关闭它,然后我启动一个 Service 并尝试使用 BroadcastReceiver 读取收到的消息,然后显示一个 AlertDialog 用户所在的任何地方。当我调用 AlertDialog 时,父 Activity 也会启动。我不希望父 Activity 自行打开。

这是 Android list 文件:

    <activity android:name=".dialog"
android:theme="@style/Theme.AppTheme.CustomTheme"
android:launchMode="singleInstance"/>

最佳答案

您可以在 Activity.java 类中代码的开头(在 onCreate 方法中)添加 AlertDialog Box。

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

//Add the AlertDialog Box code here

setContentView(R.layout.activity_name);
}

这将在 Activity 初始化之前显示对话框。

关于android - 在不打开父 Activity 的情况下打开警报对话框 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52070687/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com