简体   繁体   中英

i want location after certain time in android not when i move from one place to another

i want to to get location after certain time so i can define minimum time in method requestslocationupdates. for example i write 60 seconds so i want to get locaiton after 60 seconds. here i got it. but problem is there when i move from one place to another place so also getting locaiton but i dnt want this. i want only location after some interval..

my code is here.

locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    locationListener = new GPSLocationListener();
    Criteria criteria = new Criteria();
    //criteria.setAccuracy(Criteria.ACCURACY_COARSE);
    //criteria.setAccuracy(Criteria.ACCURACY_FINE);
    provider = locationManager.getBestProvider(criteria, false);

    locationManager.requestLocationUpdates(
            provider, 
        0, 
        0, 
        locationListener);
locationManager.requestLocationUpdates(provider,60000,0,locationListener);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM