extends android.location.Location : Location « Hardware « Android






extends android.location.Location

 

import android.location.Location;

 class CuhkLocation extends Location{
  
  private static final double latitude = 22.419005;
  private static final double longitude = 114.206904;
  
  public static final double CUHK_RANGE = 1000;
  public static final double CUHK_CLOSE_RANGE = 5000;
  
  public static final int INSIDE = 1;
  public static final int CLOSE = 2;
  public static final int FAR = 3;
  
  private static CuhkLocation cuhkLocation = null;
  
  public static CuhkLocation getInstance(){
    if(cuhkLocation==null)
      cuhkLocation = new CuhkLocation();
    return cuhkLocation;
  }
  
  private CuhkLocation() {
    super("CUBT");
    this.setLatitude(latitude);
    this.setLongitude(longitude);
  }

  public int getDistanceDescriptionTo(Location location){
    double distance = this.distanceTo(location);
    if(distance < CUHK_RANGE)
      return INSIDE;
    if(distance < CUHK_CLOSE_RANGE)
      return CLOSE;
    else
      return FAR;
  }
  
}

   
  








Related examples in the same category

1.Location service and LocationManager
2.Location service
3.Using LocationManager
4.My location
5.Display GEO location
6.Using location service for the weather
7.Using Intent to go to a geo location
8.Location based service
9.My location and Google Map
10.Custom Location Overlay
11.Get my location
12.Geo location and Google Map
13.Location Tracking
14.A light pool of objects that can be resused to avoid allocation.
15.Geo Location Util
16.C:\Java_Dev\WEB\dev\android\weatherforecastsystem-read-only\com\hci\pwf\LocationUtil.java
17.upload Data with Geo location
18.Copy a file from one location to another.
19.LocationManager.GPS_PROVIDER
20.Location util