//记录登录ID
private String idd;
private GeoPoint gp1;
private GeoPoint gp2;
private Location mLocation;
private LocationManager locMan;
         /**
 * 获取gps信息开始
 */
public void gps(){
          String serviceName=Context.LOCATION_SERVICE;
                  locMan=(LocationManager)context.getSystemService(serviceName);
          //查找到服务信息
          //criteria获取精确度的方法
          Criteria criteria=new Criteria();
          //位置解析的精度,高或低,参数
          criteria.setAccuracy(Criteria.ACCURACY_FINE);
          //是否提供海拔高度信息
          criteria.setAltitudeRequired(false);
          //是否提供方向信息
          criteria.setBearingRequired(false);
          //是否允许运营商计费
          criteria.setCostAllowed(true);
          //电池消耗,无,低,中,高参数。power——low为低
          criteria.setPowerRequirement(Criteria.POWER_LOW);
          //获取gps的信息
          String provider=locMan.getBestProvider(criteria, true);
          //通过gps获取信息
          mLocation=locMan.getLastKnownLocation(provider);
// 设置监听器,15分钟更新一次位置坐标,不考虑位置的变化。最后引用locationlistener并且实现次方法
        locMan.requestLocationUpdates(provider, 900000, 0, new LocationListener(){
            //坐标改变时触发此函数
            public void onLocationChanged(Location location) {
              updateNewLocation(location);
             }
           //provider被disable时触发此函数,比如gps被关闭
           public void onProviderDisabled(String provider) {
             updateNewLocation(null);
            }
            //provide被enable时触发此函数,比如gps被打开
           public void onProviderEnabled(String provider) {
            
           }
           //provider的转态在:可用,暂时不可用和无服务3个状态直接切换时触发此函数
           public void onStatusChanged(String provider,
               int status, Bundle extras) {
                                                    
            }
        });
        }
/**
 * GPS位置更新location
 */
private static String updateNewLocation(Location location) {
        double longi = 0;
double lati = 0;
if(location!=null){
                //lati纬度longi经度
                 longi=location.getLongitude();
                 lati=location.getLatitude();
                
        }
        return longi+","+lati;
}
/**
 * 取得GeoPoint的方法
 * @param location
 * @return gp
 */
private GeoPoint getGeoByLocation(Location location){
GeoPoint gp=null;
try{
if(location!=null){
double geoLatitude=location.getLatitude()*1E6;
double geoLongitude=location.getLongitude()*1E6;
gp=new GeoPoint((int)geoLatitude,(int)geoLongitude);
}
}catch(Exception e){
e.printStackTrace();
}
return gp;
}
/**
 * 获取两点之间距离的方法,得出的距离是m
 */
public double getdistance(GeoPoint gp1,GeoPoint gp2){
double Lat1r=ConvertDegreeToRadians(gp1.getLatitudeE6()/1E6);
double Lat2r=ConvertDegreeToRadians(gp2.getLatitudeE6()/1E6);
double Long1r=ConvertDegreeToRadians(gp1.getLongitudeE6()/1E6);
double Long2r=ConvertDegreeToRadians(gp2.getLongitudeE6()/1E6);
//地球半径(km)
double R=6371;
//计算得出是m
double d=Math.acos(Math.sin(Lat1r)*Math.sin(Lat2r)+Math.cos(Lat1r)*Math.cos(Lat2r)*Math.cos(Long2r-Long1r))*R;
return d;
}
/**
 * ConvertDegreeToRadians
 */
private double ConvertDegreeToRadians(double degrees){
return (Math.PI/180)*degrees;
}
 /**
  * 获取GPS信息结束
  */报错.
locMan=(LocationManager)context.getSystemService(serviceName);
这句话报错.有人知道错在哪吗