予具有其中我要显示一个通知允许用户来阻止它后台服务
在Android SDK文档,它说的活动是用于正常启动的活动。所以我想知道如果我需要创建活动停止服务,也可以我就直接停在用户选择通知的服务,
那么会怎么打算回叫服务停止吧..
谢谢
解决方案所以,我想知道如果我需要创建活动停止服务,也可以我就直接停在用户选择通知的服务,
您不能直接阻止来自通知服务。你可以的启动的服务,使用意图,有一个操作字符串或额外什么的服务看到在 onStartCommand ()键,触发它来调用 stopSelf()。
I have a background service in which I want to show a notification which allows the user to stop it.
In the android SDK docs it says an activity is used to normally launch an Activity. So I am wondering if I need to create an activity to stop the service or can I directly stop the service when user selects the notification,
So how would the intend call back the service to stop it..
Thanks,
解决方案So I am wondering if I need to create an activity to stop the service or can I directly stop the service when user selects the notification,
You cannot directly stop the service from a Notification. You can start the service, using an Intent that has an action string or extra or something that the service sees in onStartCommand() and triggers it to call stopSelf().
更多推荐
停止从通知后台服务
发布评论