我想显示来自服务
的警报,并且我不在乎当前是什么 Activity ,只需显示警报即可。
但是构建者需要像这样的构建
AlertDialog.Builder builder = new AlertDialog.Builder(this);
但是我如何知道当前 Activity 并传递给AlertDialog.Builder
?
最佳答案
But how I know the current activity and pass to the AlertDialog.Builder?
您不需要知道当前的 Activity 。只需从服务中使用 android:theme="@android:style/Theme.Dialog"
主题启动一个 Activity。
关于java - 从 Android 服务调用 AlertDialog.Builder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11808151/