あなたの助けが必要です。現在の lat lon を 5 分ごとに取得するアクティビティがありますgps = new GpsData(StartActivity.this);。それはうまくいきます!しかし、私が郡を離れてアクティビティが更新されたとき。それから私は現在の経度を取得しません。どうしてか分かりません。
コードは次のとおりです。
@Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listplaceholder);
        btnShowLocation = (Button) findViewById(R.id.report_btn);
        btnShowLocation.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
                Intent intent = new Intent(StartActivity.this, ReportActivity.class);
                startActivity(intent);
                finish();
            }
        });
    }
     @Override
     public void onResume() {
      super.onResume();
      autoUpdate = new Timer();
      autoUpdate.schedule(new TimerTask() {
       @Override
       public void run() {
        runOnUiThread(new Runnable() {
         public void run() {
             //start GPS
             gps = new GpsData(StartActivity.this);
             //start json download
             new task().execute();
         }
        });
       }
      }, 0, 300000); // updates each 5 min
     }
class task extends AsyncTask<String, String, Void>
{
private ProgressDialog progressDialog = new ProgressDialog(StartActivity.this);
    InputStream is = null ;
    String result = "";
    protected void onPreExecute() {
       progressDialog.setMessage("Status Update...");
       progressDialog.show();
       progressDialog.setOnCancelListener(new OnCancelListener() {
    @Override
        public void onCancel(DialogInterface arg0) {
        task.this.cancel(true);
       }
    });
     }
       @Override
    protected Void doInBackground(String... params) {
            //get Location Data
               double latitude = gps.latitude;
               double longitude = gps.longitude;
               String mlat = String.valueOf(latitude);
               String mlon = String.valueOf(longitude);
               //if (gps.latitude != 0.0) {
           JSONObject json = jsonFunctions.getJSONfromURL("http://myurl);
これが私のGpsDataです
public class GpsData extends Service implements LocationListener {    
public GpsData(Context context) {
            this.mContext = context;
            getLocation();
        }
        public Location getLocation() {
        // Get the location manager
        locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
        return null;
      }
      /* Request updates at startup */
      protected void onStart() {
      }
      /* Remove the locationlistener updates when Activity is paused */
      protected void onPause() {
        locationManager.removeUpdates(this);
      }
      @Override
      public void onLocationChanged(Location location) {
          latitude = location.getLatitude();
          longitude = location.getLongitude();
          time = location.getTime();
          speed = location.getSpeed();
      }
それは簡単です: 私は 5 分ごとに現在の緯度経度を取得し、現在の郡の現在のデータでリスト ビューを更新します... どうすればこれを行うことができますか?