意图服务永远不会被调用

Sea*_*ean 7 service android android-intent

我正在尝试Intent服务.这就是我用它来称呼它

    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);}});
Run Code Online (Sandbox Code Playgroud)

但是在我的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();
...
Run Code Online (Sandbox Code Playgroud)

到底是怎么回事?

谢谢

PS.我正在使用它,因为我想用一个报警管理器来调用它.但是,在按钮单击时,我想显示一个进度对话框,我将在哪里放置意向服务的进度对话框?(到目前为止,我只有使用异步任务的经验)

Phi*_*art 15

声明你的服务AndroidManifest.xml?除非声明如下,否则不会调用它:

<manifest ... >
  ...
  <application ... >
      <service android:name=".ExampleService" />
      ...
  </application>
</manifest>
Run Code Online (Sandbox Code Playgroud)