【发布时间】:2013-11-19 14:00:27
【问题描述】:
我的 STICKY 服务有问题。我在 MainActivity.class 中调用它并绑定它:
MainActivity:
Intent intent = new Intent(this, MyService.class);
ComponentName MyCompName= startService(intent);
bindService(intent, MyConnection, Context.BIND_AUTO_CREATE);
还有……
我的服务
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
return START_STICKY;
}
我希望此服务运行 STICKY 并且永远不会关闭或重新启动。但是当我关闭我的应用程序时,会调用 MyService 的 onCreate()-Method 并重置所有变量,我不知道为什么。
顺便说一句:我不叫 stopService!
【问题讨论】:
标签: android android-service sticky