我想以静态方式启动服务。所以从我的 Activity 中我打电话
SpeechActivationService.makeStartServiceIntent(
this.getApplicationContext(),
"WordActivator");
这是从服务类 http://dpaste.com/hold/928115/ 扩展的实际类如您所见,有几个日志点,例如在 onCreate 方法中。
这没有记录。仅当我将日志文本放入 makeStartServiceIntent
方法时才会出现,但不会出现在 onCreate
方法中。
这是 makeStartServiceIntent
方法:
public static Intent makeStartServiceIntent(Context context,
String activationType) {
Intent i = new Intent(context, SpeechActivationService.class);
i.putExtra(ACTIVATION_TYPE_INTENT_KEY, activationType);
return i;
}
在我的 list 文件中
<service android:name="root.gast.speech.activation.SpeechActivationService"/>
知道为什么服务没有启动吗?
最佳答案
除了您没有发布显示 startService()
的代码之外, list 中您的 Service
的包名称似乎与您的 SpeechActivationService
类(假设您发布的代码链接是您项目中的实际 SpeechActivationService
类,而不仅仅是您从中复制的类)。
<service android:name="com.mkyong.android.SpeechActivationService"/>
关于android - 未调用android服务的onCreate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14877442/