【发布时间】:2014-07-22 03:35:38
【问题描述】:
我有一个服务:
[Service]
public class LocationService : Service, ILocationListener
{
....
public override StartCommandResult OnStartCommand(...)
{ return StartCommandResult.Sticky; }
}
在一种环境中开始
new Task(() =>
{
Application.Context.StartService(new Intent(Application.Context, typeof(LocationService)));
}).Start();
如何从其他地方停止此服务?
我尝试过这样做:
Application.Context.StopService(new Intent(Application.Context, typeof(LocationService)));
但它并不总是有效
【问题讨论】:
-
在什么情况下它似乎不起作用?
-
随机大小写。它的背景 gps 服务。有时会停止,有时不会