我有一个activity "PSActivity“和一个IntentServive "StalkService”。我正在启动服务,但服务永远不会执行,至少根据调试器是这样的。下面的代码在PSActivity中启动服务,我确信这将被执行……
public void cbRealTime_Clicked(View v) {
//start the StalkService
if (cbRealTime.isChecked()) {
Intent i = new Intent(this, StalkService.class);
i.putExtra("mystuff", "this is my stuff");
this.startService(i);
} else {
//stop the service here
}
}以下是该服务的代码...
public class StalkService extends IntentService {
public StalkService() {
super("StalkService");
// must override constructor
}
@Override
protected void onHandleIntent(Intent intent) {
// TODO Auto-generated method stub
String data = (String) intent.getExtras().get("mystuff");
data = data + "debug";
}
}我在data = data +“debug”处设置了一个断点,这个断点永远不会命中。看起来onHandleIntent永远不会被执行。我正在使用模拟器进行测试。我忘了做什么?谢谢,加里
发布于 2012-10-11 07:08:53
这个问题得到了CommonsWare评论的回复。我无法在清单文件中注册服务。加里
https://stackoverflow.com/questions/12829071
复制相似问题