本文介绍了没有调用onStartCommand()遵循坠毁服务于Android 2.3的重启的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经与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开发人员小组关于它的主题:<一href="http://groups.google.com/group/android-developers/browse_thread/thread/d87fb390c13d141d/52f7154ab49f229?hl=en&q=dianne+hackborn+onstartcommand+bug#">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.

这篇关于没有调用onStartCommand()遵循坠毁服务于Android 2.3的重启的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-29 20:15