I am working on a chunk of code that involves my code holding up for a certain amount of time in order for something to work properly. However the code does hang when the 35 seconds are initiated however its not working the way I want it to. IE I do not get the desired output I want.
Here is some code I am working on.
LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
mlocListener);
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
1000L, 1.0f, (LocationListener) this);
boolean isGPS = locationManager
.isProviderEnabled(LocationManager.GPS_PROVIDER);
// Methods to make the code wait 35 seconds
int time = 35000;
try {
Thread.sleep(time);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent WriteOut = new Intent(context, WriteOut.class);
WriteOut.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(WriteOut);
I am trying to print out the current GPS co-ordinates after the system has a chance to launch / acquire the GPS signal of the device.
Any tips on how to pull this off would be wonderful since its clear I am doing something wrong.