Android 意图服务从未被呼叫

Android 意图服务从未被呼叫,android,service,android-intent,Android,Service,Android Intent,我正在尝试意向服务。这就是我常说的 Button updateLocation = (Button) findViewById(R.id.btnUpdateLocation); updateLocation.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO

我正在尝试意向服务。这就是我常说的

    Button updateLocation = (Button) findViewById(R.id.btnUpdateLocation);
        updateLocation.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                Intent updateLocIntent=new Intent(ImTracking.this,UpdateLocation.class);
                startService(updateLocIntent);}});
然而,在我的UpdateLocation类中,它从未达到我的任何断点

    public class UpdateLocation extends IntentService{

    public UpdateLocation() {
        super("UpdateLocation");
    }


    @Override
    protected void onHandleIntent(Intent intent) {

                SharedPreferences prefs = getSharedPreferences("Settings", 0);
                final String id = prefs.getString("ID", "");
                DefaultHttpClient httpclient = new DefaultHttpClient();
                HttpPost httpost = new HttpPost(
                        "http://iphone-radar.com/gps/gps_locations");

                JSONObject holder = new JSONObject();
...
发生了什么事

谢谢


另外,我之所以使用它,是因为我想用报警管理器来调用它。但是,单击按钮时,我希望显示一个进度对话框,我将在哪里放置intent服务的进度对话框?(到目前为止,我只有处理异步任务的经验)

添加下面的行将允许您逐步完成服务。确保在不调试时将其删除。如果您不这样做,您的服务处理将在该点停止,并且不会继续

android.os.Debug.waitForDebugger();
您在
AndroidManifest.xml
中找到了吗?除非声明如下,否则不会调用它:

<manifest ... >
  ...
  <application ... >
      <service android:name=".ExampleService" />
      ...
  </application>
</manifest>

...
...

我不是这方面的专家,但您不需要注册您的接收器并为您希望捕获的特定意图设置过滤器吗?当我完成这项工作时,我是在代码中完成的,但我认为它可以在Manifest/xml中完成。你能给我举个例子吗?我不太清楚你所说的过滤器是什么意思有时你在
AndroidManifest.xml
中给出了错误的
android:name
,它可能没有包名,我把这一行放在startservice之前还是之后?它放在你的IntentService内部。将其放在断点之前或onHandleIntent()的开头。该名称与清单标记中定义的
包相对。如果您的清单标签将
包定义为
com.example
,并且您的服务位于
com.example.data
中,则该服务的名称需要为
.data.ExampleService