android - 为什么服务不应该启动 Activity ?

标签 android service

在状态通知文档中here我读了:

A background service should never launch an activity on its own in order to receive user interaction. The service should instead create a status notification that will launch the activity when selected by the user.

为什么这个“不应该”?

提前致谢

最佳答案

因为服务在后台发生,所以用户很可能在您的服务运行时做其他事情。如果您只是通过将您的 Activity 放在上面来打断他们正在做的事情,他们最多只会感到困惑,最坏的情况是会感到恼火。

他们建议使用通知,因为这样会提醒用户您想要开始一项 Activity ,但他们可以选择“在他们自己的时间”随时开始,方法是在通知栏中点击它。

关于android - 为什么服务不应该启动 Activity ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11263772/

相关文章:

angular - 是否可以在 Angular 中将 2 个 http 响应合并为一个?

soap - 将 WSDL 转换为其各自的 HTTP 绑定(bind)

c# - 从服务执行 shell 命令

android - 适用于 Jelly Bean 但不适用于 Kitkat 的相机 API

使用 ssh 的 Java Web 服务(远程 Linux 连接)

android - 寻找关于如何在我的应用程序中可靠地维护联系人列表的明确答案

Android:外部网站和 CSS 使用自定义字体 (Arial) 的 WebView

json - 需要帮助解析 JSON 响应 Angular 4

android - onserviceconnected 从未调用过 : android

java - 如果 RecyclerView 中的列表为空,我想显示带有空消息的 Toast