1

I have an activity "PSActivity" and an IntentServive "StalkService". I am starting the service but the service never executes, at least according to the debugger. The following code starts the service inside PSActivity and I am sure this is getting executed...

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
    }
}

Here is the code for the service...

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";

    }
}

I have a breakpoint set at data = data + "debug"; that never is hit. It looks like onHandleIntent is never getting executed. I'm testing with the emulator. What am I forgetting to do? Thanks, Gary

4

1 回答 1

0

CommonsWare 评论回答了这个问题。我未能在清单文件中注册服务。加里

于 2012-10-10T23:08:53.280 回答