Code example for Location

Methods: distanceTogetAccuracygetTime

    if (network == null) {
    Location older=(gps.getTime() < network.getTime() ? gps : network);
    Location newer=(gps == older ? network : gps);
    // older and less accurate fixes suck 
    if (older.getAccuracy() <= newer.getAccuracy()) {
    // if older is within error radius of newer, assume 
    // not moving and go with older (since has better 
    // accuracy, else would have been caught by previous 
    // condition) 
    // ideally, this would really be "if the odds of 
    // the older being within the error radius of the 
    // newer are higher than 50%", taking into account 
    // the older one's accuracy as well -- the 
    // implementation 
    // of this is left as an exercise for the reader 
    if (newer.distanceTo(older) < newer.getAccuracy()) {
    // if all else fails, choose the newer one -- the device 
    // is probably moving, and so we are better off with the 
Contextual code suggestions in your IDE  Get Codota for Java