Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想显示来自 a 的警报service,我不在乎当前是什么活动,只显示警报。
service
但是建设者需要像这样的建设
AlertDialog.Builder builder = new AlertDialog.Builder(this);
但是我如何知道当前的活动并传递给AlertDialog.Builder?
AlertDialog.Builder
但是我如何知道当前活动并传递给 AlertDialog.Builder?
您不需要知道当前的活动。只需使用android:theme="@android:style/Theme.Dialog"服务中的主题开始一项活动。
android:theme="@android:style/Theme.Dialog"