How to get gps location for every half an hour android? -
i have switch on gps once every half hour , location , switch off there code function new android kindly me pls.
thank you.
here code:
public void checklocation(view v) { //initialize location manager manager = (locationmanager) getsystemservice(context.location_service); //check if gps enabled //if not, notify user toast if (!manager.isproviderenabled(locationmanager.gps_provider)) { toast.maketext(this, "gps disabled.", toast.length_short).show(); } else { //get location provider location manager //empty criteria searches through providers , returns best 1 string providername = manager.getbestprovider(new criteria(), true); location location = manager.getlastknownlocation(providername); textview tv = (textview)findviewbyid(r.id.locationresults); if (location != null) { tv.settext(location.getlatitude() + " latitude, " + location.getlongitude() + " longitude"); } else { tv.settext("last known location not found. waiting updated location..."); } //sign notified of location updates every 15 seconds - production code should @ least minute manager.requestlocationupdates(providername, 60000*3, 1, this); } }
i make runnable function. example
you shoud set handler.postdelayed(r, 5400000); (if calculate right). value miliseconds.
Comments
Post a Comment