Android:从后台线程引发 AlertDialog

标签 android dialog multithreading background

在我的 Activity 中,后台线程中进行了一些操作,该线程在 Activity_1 中启动。后台线程的处理需要一段时间,我想在完成时通过 AlertDialog 通知用户。但是,用户可能同时更改为 Activity_2 或 Activity_3,我希望始终在当前 Activity 中弹出 AlertDialog。

知道如何实现这一点吗?

最佳答案

我最终在我的后台线程中做了类似的事情。它有效,但不确定它是否是一个“好的”解决方案。

Looper.prepare();
mActivity.showDialogAlertDefault();
Looper.loop();
Looper.myLooper().quit();

关于Android:从后台线程引发 AlertDialog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1796181/

相关文章:

iphone - 是否有适用于 iPhone 和/或 Android 手机的好的 OCR API?

java - 如何以方形对齐单选组项目

android - 由 30 多个 View 组成的自定义 View 呈现缓慢

android - 让 Activity 始终在堆栈顶部,还是在恶意应用启动 Activity 时保持焦点?

windows - 什么会导致 C++Builder/Delphi 线程和应用程序无法关闭?

android - 您如何从 android 上的 unity 读取公共(public)下载目录

android - 在 Android 主屏幕中弹出对话框

android - 来自 SQLite 数据的自定义对话框

c# - 立即退出 C# 中的 Parallel.For 循环

c - 打开 MP 性能不佳/令人困惑