没有调用onStartCommand()遵循坠毁服务于Android 2.3的重启重启、服务于、onStartCommand、Android

2023-09-05 06:18:22 作者:ㄣ你是我无法回避的意外,我会收藏,你给的意外。

我已经与Android服务重新启动的问题。我建立针对API版本7和采用Android 2.3.3的设备上运行。

I have a problem with Android service restart. I am building against API version 7 and running on a device with Android 2.3.3.

现在的问题是,当我的服务被杀害的系统和以后重新启动,仅的onCreate()我的服务被调用。 不执行 onStartCommand code()。如果我开始了第一次我的应用程序,在 onStartCommand的code()的正常执行,一切工作正常,直到系统杀死我的服务,那么该服务会无法正常重新启动。

The problem is, that when my service is killed by the system and is later restarted, only the onCreate() of my service is called. code in onStartCommand() is not executed. If I start my application for the first time, the code in onStartCommand() is normally executed and all works fine, until system kills my service, then the service will not restart correctly.

文档中说, onStartCommand()总是被调用时,服务重新启动。的在服务重新启动的情况下, onStartCommand()应该调用空意图。这不是我的情况。

Documentation says that onStartCommand() is always called when a service is restarted. In the case of service restart, the onStartCommand() should be called with null intent. This is not my case.

任何想法,为什么会发生这种情况?

Any idea why this could happen?

推荐答案

您可能会看到在姜饼的错误。有在Android开发人员小组关于它的主题:onStartCommand错误线程

You might be seeing a bug in Gingerbread. There was a thread in the android-developers group about it: onStartCommand bug thread

见编号为26戴安娜Hackborn的详细信息后。

See the post numbered 26 by Dianne Hackborn for details.