我想以静态方式启动服务。所以从我的活动中我打电话
SpeechActivationService.makeStartServiceIntent(
this.getApplicationContext(),
"WordActivator");
这是从服务类扩展的实际类http://dpaste.com/hold/928115/ http://dpaste.com/hold/928115/正如您所看到的,有几个日志点,例如在 onCreate 方法中。
这没有记录。仅当我输入日志文本时makeStartServiceIntent
它出现的方法,但不在onCreate
method.
这是makeStartServiceIntent
method:
public static Intent makeStartServiceIntent(Context context,
String activationType) {
Intent i = new Intent(context, SpeechActivationService.class);
i.putExtra(ACTIVATION_TYPE_INTENT_KEY, activationType);
return i;
}
在清单文件中我有
<service android:name="root.gast.speech.activation.SpeechActivationService"/>
有什么想法为什么服务没有启动吗?
除了你没有发布代码显示startService()
,它看起来像你的包名称Service
清单中的内容与您的不匹配SpeechActivationService
class (假设您发布的代码链接是实际的SpeechActivationService
您项目中的类,而不仅仅是您从中复制的类).
<service android:name="com.mkyong.android.SpeechActivationService"/>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)