I may have a simple piece of code here for you. When you're starting the GPS, you just define time and distance limitations. Also don't forget to kill this when you exit your app (last method below).
I may have a simple piece of code here for you. When you're starting the GPS, you just define time and distance limitations. Also don't forget to kill this when you exit your app (last method below) private static LocationListener gpsLocationListener = null; /* GPS will not detach and update every 30 minutes if the delta > 25 meters */ private void getGPSLocation(Context context){ gpsLocationListener = new GPSLocationListener(); locationManager.
RequestLocationUpdates(LocationManager. GPS_PROVIDER, 1800000, 25, gpsLocationListener); } private class GPSLocationListener implements LocationListener{ public void onLocationChanged(Location location){ if(location! = null){ final double lat = location.getLatitude(); final double lng = location.getLongitude(); // can do your other implementation here // } } @Override public void onProviderDisabled(String provider){ } @Override public void onProviderEnabled(String provider){ } @Override public void onStatusChanged(String provider, int status, Bundle extras){ } } private void killGPS(){ if(locationManager!
= null && gpsLocationListener! = null){ locationManager. RemoveUpdates(gpsLocationListener); } } } Hope this helps -serkan.
Im a little new to java as well, If I want to call this method do I have to use GPSLocationListener. GetGPSLocation(this) or just getGPSLocation(this) (from my main class splash. Class) – Sean Oct 1 at 4:43 If your main activity is Splash.
Java and if that's the last Activity to be killed when the user exits, then it's OK, you can call getGPSLocation(this) in Splash. However, if kill your splash after few seconds and take user to another Activity like Home for example, this code should live and getGPSLocation(this) should be called there (in Home. Java).
I hope I made sense here Sean, let me know if you need any help. – serkan Oct 1 at 15:24 When I call get getGPSLocation(this) all it does is turn on the gps correct? What do I do to extract the latitude and longitude doubles?
– Sean Oct 1 at 22:02 It's in the code Sean, take a look at GPSLocationListener's onLocationChanged method; it's called by the system finds a gps fix and I've already put the statements which gets the lat and lng. – serkan Oct 1 at 0:53 I'm still having a problem when I need to turn on the gps when its in the background. If I turn it on when its in the home screen and let it live there, what happens if I turn it off with another service but want to turn it on again in say 30 mins?
Thanks – Sean Oct 1 at 21:50.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.