Hey,
Right now when trying to get a user location I start with the GPS Provider. I have a timer set for 30 seconds, If a location is not found in 30 seconds the timer goes off and stops that location request. When that happens I move to the Passive Provider. After 30 seconds if a location is not found I stop the location request and move to the Network Provider.
My issue is that when the network provider gets called it never does anything. If I start with the network provider it goes off just fine and returns a location back to me. Below is the code I am trying to use:
gpsTimer.schedule(new TimerTask(){
@Override
public void run() {
startPassive();
}
}, 30000);
currentTimer = "GPS";
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
private void startPassive(){
locationManager.removeUpdates(locationListener);
//Now we want to try for a Passive Fix
currentTimer = "Passive";
passiveTimer.schedule(new TimerTask(){
@Override
public void run() {
startNetwork();
}
}, 30000);
Looper.prepare();
Looper.myLooper().quit();
locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 0, 0, locationListener);
private void startNetwork(){
locationManager.removeUpdates(locationListener);
currentTimer = "Network";
Looper.prepare();
Looper.myLooper().quit();
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
any help or suggestions would be greatly appreciated. Thank so much in advance.
No comments:
Post a Comment