在状态通知文档中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/