KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am writing an app that records a new gps location every ten minutes on the dot. I've tried location pollers, putting the location listener in a service, and putting the location listener in an activity but none of these methods work for me. I need a method to turn on the gps location listener 2 minutes before I begin recording my location data (to give the gps ample time to find a location or determine there is no signal). I've been doing this by using an alarm that calls my gpsActivity 2 minutes before I call my updatelocation class. My updatelocation class then takes the gpsActivity's locationmanager and extracts a location from it. In theory this should work but when I put it on my phone I always get bad data (accuracy is too low or no signal at all) If someone could help me out I would be extremely grateful. Thanks Alarm calls this class 2 mins before update location public class GPSActivity extends Activity { public static LocationListener loc_listener = null; public static LocationManager locationManager = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); getGPS(); } public static void getGPS() { if (loc_listener == null) { loc_listener = new LocationListener() { @Override public void onStatusChanged(String provider, int status, Bundle extras) {} @Override public void onProviderEnabled(String provider) {} @Override public void onProviderDisabled(String provider) {} @Override public void onLocationChanged(Location location) {} }; } locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0,
Tags (comma-separated)
Save Edits
Cancel