っています。この活動の中で、私は実行されるAsyncTaskで働いていない
-
21-09-2019 - |
質問
private class ExecuteLocations extends AsyncTask<String, Void, Void>{
private final ProgressDialog dialog = new ProgressDialog(ListProfiles.this);
protected void onPreExecute() {
//this.dialog.setMessage("Starting pre-execute...");
//this.dialog.show();
}
@Override
protected Void doInBackground(String... arg0) {
check_profiles_lm=(LocationManager) ListProfiles.this.getSystemService(LOCATION_SERVICE);
myLocListen = new LocationListener(){
@Override
public void onLocationChanged(Location location) {
HashMap params = new HashMap();
params.put("lat", Double.toString(location.getLatitude()));
params.put("long", Double.toString(location.getLongitude()));
postData("http://mydomain.com",params);
}
@Override
public void onStatusChanged(String provider, int status,Bundle extras) {
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onProviderEnabled(String provider) {
}
};
check_profiles_lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 30000, 0, myLocListen);
return null;
}
protected void onPostExecute(final Void unused) {
if (this.dialog.isShowing()) {
//this.dialog.dismiss();
}
//Do something else here
}
}
基本的には、私の目的は:
- 常にポストの緯度経度に私のサイトは毎分ほど。
- もちろん、こういう仕事がしたい別のスレッドでなべての空港を表示一部の空港を表っUI。このAsyncTaskれを解決する---あな参加をお待ちしておりエラーというのではないでしょうか。
でどこまでできるの達成に私の目的は?でもパッチとアップグレードでスキャンの場所やウェブを分しみいただけます。
るようになったら自分へのごonCreate方法は以下のようになっています.この基本です。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
new ExecuteLocations().execute();
setContentView(R.layout.main_list);
}
解決
休憩での3ステップ:
- いい仕事をw/o AsyncTask
- 作を行っAsyncTask、プログです。e("母","gotcha)
doInBackground(...)
ていることを確認で - と結合します。
この場合、いろん Service
起 AlarmManager
.んだ後?
他のヒント
をしていきます。要らないタイマー又はAlarmManagerとして登録すための場所にイベントの適切な行動ができる.
の一例を聴位置のイベントです http://code.google.com/p/android-bluetooth-on-motion/source/browse/#svn/trunk/BluetoothOnMotion/src/com/elsewhat
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, MIN_TIME_NETWORK, MIN_DISTANCE_NETWORK,locationListener);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME_GPS, MIN_DISTANCE_GPS,locationListener);
所属していません StackOverflow