微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – Intent Service永远不会被调用

我正在尝试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);}});

但是在我的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();
...

到底是怎么回事?

谢谢

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

解决方法

你在AndroidManifest.xml中有 declare your service吗?除非声明如下,否则不会调用它:
<manifest ... >
  ...
  <application ... >
      <service android:name=".ExampleService" />
      ...
  </application>
</manifest>

原文地址:https://www.jb51.cc/android/316875.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐