Question

Suppose an Android application demands a GPS updates every 6 seconds, or when the distance of...

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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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);
}

  
}

Add a comment
Know the answer?
Add Answer to:
Suppose an Android application demands a GPS updates every 6 seconds, or when the distance of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT