【发布时间】:2011-08-02 02:15:01
【问题描述】:
我开发了一个 GPS 应用程序。我的应用程序有一项服务,负责通过服务器将 GPS 发送到服务器....
Service -----> AysncTask(sendServer)
// then in service i broadcast some variable
myFilteredResponse = new Intent(GPS_FILTER);
myFilteredResponse.putExtra("latitude", Double.valueOf(twoFormat.format(location.getLatitude())));
myFilteredResponse.putExtra("longitude", Double.valueOf(twoFormat.format(location.getLongitude())));
myFilteredResponse.putExtra("network", MyGPS.cur_network_status);
然后在我的 Activity 中创建一个广播接收器来接收所有这些变量 n 它工作正常,然后当我们有新的 lat n lon 时我的 UI 会改变
在我的 AysncTask 中,当发送到服务器时,我将获得服务器的位置标识,所以我想更新我的 UI 界面,所以我 1 2 也使用广播,但它不起作用!
结构
broadcast
service ( on location changed ) -------------> UI interface
broadcast??
AsyncTask -------------> UI interface
我不能在我的 AsyncTask 中使用 sendBroadcast,因为我的 AsyncTask 不是活动任何想法?
【问题讨论】:
标签: android service android-asynctask