Suppose an Android application demands a GPS updates every 6 seconds, or when the distance of the device exceeds a quarter kilometer from previous location. Further, suppose that your LocationListener variable name is locListener. Write the GPS updates callback method using the necessary parameters to meet the time and distance requirements.
android code please for mobile apps
public class MyRunnable implements Runnable
{
private LocationManager manager;
private LocationListener listener;
@Override
public void run()
{
removeUpdates();
manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
listener = new LocationListener() {
@Override
public void onLocationChanged(Location loc) {
location = loc;
latitude = loc.getLatitude();
longitude = loc.getLongitude();
accuracy = Math.round(loc.getAccuracy());
handler.sendMessage(Message.obtain(handler, KEY_MESSAGE_LOCATION_CHANGED));
checkForArrival();
}
};
if(!arrived)
manager.requestLocationUpdates(provider, updateInterval, 0,
listener);
}
/**
* Removes location updates from the LocationListener.
*/
public void removeUpdates() {
if(!(manager == null || listener == null))
manager.removeUpdates(listener);
}
}
Suppose an Android application demands a GPS updates every 6 seconds, or when the distance of...