質問

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 
    }

}

基本的には、私の目的は:

  1. 常にポストの緯度経度に私のサイトは毎分ほど。
  2. もちろん、こういう仕事がしたい別のスレッドでなべての空港を表示一部の空港を表っUI。このAsyncTaskれを解決する---あな参加をお待ちしておりエラーというのではないでしょうか。

でどこまでできるの達成に私の目的は?でもパッチとアップグレードでスキャンの場所やウェブを分しみいただけます。

るようになったら自分へのごonCreate方法は以下のようになっています.この基本です。

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
            new ExecuteLocations().execute();
            setContentView(R.layout.main_list);
    }
役に立ちましたか?

解決

休憩での3ステップ:

  1. いい仕事をw/o AsyncTask
  2. 作を行っAsyncTask、プログです。e("母","gotcha) doInBackground(...) ていることを確認で
  3. と結合します。

この場合、いろん ServiceAlarmManager.んだ後?

他のヒント

をしていきます。要らないタイマー又は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);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top