【发布时间】:2011-11-06 05:42:09
【问题描述】:
我正在尝试 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。我使用它是因为我想用警报管理器调用它。但是,在单击按钮时,我想显示一个进度对话框,我将在哪里放置意图服务的进度对话框? (到目前为止,我只有处理异步任务的经验)
【问题讨论】:
-
我不是这方面的专家,但您不需要注册您的接收器并为您希望捕获的特定意图设置一个过滤器吗?当我完成此操作后,我在代码中完成了它,但我认为它也可以在 Manifest/xml 中完成
-
你能给我举个例子吗?我不太清楚你所说的过滤器是什么意思
-
有时你在
AndroidManifest.xml中给错了android:name,可能没有包名
标签: android service android-intent