import static android.location.LocationManager.GPS_PROVIDER;\r
\r
public class NMEAListener implements NmeaListener, LocationListener {\r
- private static boolean listening=false;\r
+ private static boolean listening = false;\r
\r
- public boolean isListening(){\r
+ public boolean isListening() {\r
return listening;\r
}\r
\r
private double longitude;\r
private double latitude;\r
\r
- private boolean noStop=false;\r
+ private boolean noStop = false;\r
\r
\r
private int SearchTimeout = 120;\r
- private int noSignalCount=0;\r
- private int searchCout=0;\r
- private GPS_CURRENT_STATUS gpsMode;\r
+ private int noSignalCount = 0;\r
+ private int searchCout = 0;\r
+ private GPS_CURRENT_STATUS gpsMode;\r
int numberOfSatellites;\r
Runtime runtime;\r
\r
- private static int MaxFixedTimes=3;\r
+ private static int MaxFixedTimes = 3;\r
\r
- private static int locationFixedCount=0;\r
+ private static int locationFixedCount = 0;\r
\r
\r
- private static location_callback mCallback=null;\r
- public interface location_callback{\r
+ private static location_callback mCallback = null;\r
+\r
+ public interface location_callback {\r
public void on_locating_changed(GPS_locationStatus gps_status);\r
}\r
- public static void set_callback(location_callback callback){\r
- mCallback=callback;\r
+\r
+ public static void set_callback(location_callback callback) {\r
+ mCallback = callback;\r
}\r
\r
private GPS_locationStatus gps_status = new GPS_locationStatus();\r
- public GPS_locationStatus get_gps_status(){\r
+\r
+ public GPS_locationStatus get_gps_status() {\r
return gps_status;\r
}\r
\r
\r
- public void setNoStop(boolean nostop){\r
- noStop=nostop;\r
- ICLogger.i("setNoStop "+nostop);\r
- if (noStop==false ){\r
- switch (runtime.getLocationInstance().getWorkingMod()){\r
+ public void setNoStop(boolean nostop) {\r
+ noStop = nostop;\r
+ ICLogger.i("setNoStop " + nostop);\r
+ if (noStop == false) {\r
+ switch (runtime.getLocationInstance().getWorkingMod()) {\r
case ICLocation.CUSTOM_MOD:\r
case ICLocation.EMERGNECY_MOD:\r
case ICLocation.REALTIME_MOD:\r
\r
}\r
}\r
+\r
public NMEAListener(LocationManager paramLocationManager, Runtime paramRuntime) {\r
this.locationManager = paramLocationManager;\r
this.runtime = paramRuntime;\r
}\r
\r
- static int satindex=0;\r
+ static int satindex = 0;\r
+\r
public void onNmeaReceived(long paramLong, String nmeastr) {\r
// EqcAlgorithmNative.native_EqcAlgorithmMethod5(paramString);\r
// ICLogger.i("Nmea :"+nmeastr+" "+paramLong);\r
\r
- if (Config.LOG_TOFILE) FileOutputUtil.fileOutputRaw(this.runtime.getCacheDir(),"Nmea",nmeastr);\r
+ if (Config.LOG_TOFILE)\r
+ FileOutputUtil.fileOutputRaw(this.runtime.getCacheDir(), "Nmea", nmeastr);\r
\r
- if(nmeastr.startsWith("$RD_RSSI")) {\r
+ if (nmeastr.startsWith("$RD_RSSI")) {\r
\r
searchCout++;\r
- if (mCallback !=null)\r
+ if (mCallback != null)\r
mCallback.on_locating_changed(get_gps_status());\r
gps_status.numSatelliteList.clear();\r
- gps_status.search_time_cost=searchCout;\r
+ gps_status.search_time_cost = searchCout;\r
}\r
\r
\r
- if (nmeastr.startsWith("$GPGLL,")){\r
- String tmplist[]=nmeastr.split(",");\r
+ if (nmeastr.startsWith("$GPGLL,")) {\r
+ String tmplist[] = nmeastr.split(",");\r
// GPGLL编辑\r
//(地理定位信息)\r
// 例:$GPGLL,4250.5589,S,14718.5084,E,092204.999,A*2D\r
// 字段5:UTC时间,hhmmss.sss格式\r
// 字段6:状态,A=定位,V=未定位\r
// 字段7:校验值($与*之间的数异或后的值)\r
- String Lat=tmplist[1];\r
- String lon=tmplist[3];\r
- String fixed=tmplist[6];\r
+ String Lat = tmplist[1];\r
+ String lon = tmplist[3];\r
+ String fixed = tmplist[6];\r
// ICLogger.i("GPGLL Lat="+Lat+",Lon="+lon+",fixed="+fixed);\r
\r
- }else if (nmeastr.startsWith("$GPRMC,")) {\r
+ } else if (nmeastr.startsWith("$GPRMC,")) {\r
// GPRMC编辑\r
//(推荐定位信息数据格式)\r
// 例:$GPRMC,024813.640,A,3158.4608,N,11848.3737,E,10.05,324.27,150706,,,A*50\r
// 字段11:磁偏角方向,E=东W=西\r
// 字段12:模式,A=自动,D=差分,E=估测,N=数据无效(3.0协议内容)\r
// 字段13:校验值($与*之间的数异或后的值)\r
- String tmplist[]=nmeastr.split(",");\r
- String utctime=tmplist[1];\r
- String Lat=tmplist[3];\r
- String lon=tmplist[5];\r
- String fixed=tmplist[2];\r
- String speed=tmplist[7];\r
+ String tmplist[] = nmeastr.split(",");\r
+ String utctime = tmplist[1];\r
+ String Lat = tmplist[3];\r
+ String lon = tmplist[5];\r
+ String fixed = tmplist[2];\r
+ String speed = tmplist[7];\r
// ICLogger.i("GPRMC GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed+",speed="+speed);\r
// if (Config.LOG_TOFILE)\r
// FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "GPRMC GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed+",speed="+speed);\r
}\r
\r
\r
- }else if (nmeastr.startsWith("$GPGSV,")) {\r
+ } else if (nmeastr.startsWith("$GPGSV,")) {\r
\r
// GPGSV编辑\r
// (可见卫星信息)\r
//// 字段15:信噪比(00-99)dbHz\r
// 字段16:校验值($与*之间的数异或后的值)\r
\r
- String tmplist[]=nmeastr.split(",");\r
- int maxPageCount=Integer.valueOf(tmplist[1]);\r
- int currentPage=Integer.valueOf(tmplist[2]);\r
- int SatlitesCount=Integer.valueOf(tmplist[3]);\r
- if (maxPageCount>0 && currentPage==1){\r
+ String tmplist[] = nmeastr.split(",");\r
+ int maxPageCount = Integer.valueOf(tmplist[1]);\r
+ int currentPage = Integer.valueOf(tmplist[2]);\r
+ int SatlitesCount = Integer.valueOf(tmplist[3]);\r
+ if (maxPageCount > 0 && currentPage == 1) {\r
//第一页把数组初始化一遍。\r
- satindex=0;\r
+ satindex = 0;\r
runtime.getLocationInstance().numSatelliteList.clear(); //清除 SNR >0的卫星\r
runtime.getLocationInstance().max3Satellite.clear(); //清除 最大3个星值\r
\r
- gps_status.satlite_numbss=SatlitesCount;\r
+ gps_status.satlite_numbss = SatlitesCount;\r
}\r
- int satcount=(tmplist.length-4)/4;\r
+ int satcount = (tmplist.length - 4) / 4;\r
// ICLogger.i("Nmea :"+nmeastr+" "+satcount);\r
runtime.getLocationInstance().set_adding_satlite_flag(true);\r
- for (int i=0;i<satcount;i++){\r
+ for (int i = 0; i < satcount; i++) {\r
satindex++;\r
- String prn=tmplist[i*4+4];\r
- String snr=tmplist[i*4+4+3];\r
- if (snr.contains("*")){\r
- snr=snr.substring(0,snr.indexOf("*"));\r
+ String prn = tmplist[i * 4 + 4];\r
+ String snr = tmplist[i * 4 + 4 + 3];\r
+ if (snr.contains("*")) {\r
+ snr = snr.substring(0, snr.indexOf("*"));\r
+ }\r
+ if (snr.trim().isEmpty()) {\r
+ snr = "0";\r
}\r
- if (snr.trim().isEmpty()){\r
- snr="0";\r
- }\r
- ICLogger.i("Sat="+satindex+",prn="+prn+",snr="+snr);\r
-\r
- int intprn=Integer.valueOf(prn);\r
- float floatsnr=Float.valueOf(snr);\r
- if (floatsnr>0) {\r
+ ICLogger.i("Sat=" + satindex + ",prn=" + prn + ",snr=" + snr);\r
+\r
+ int intprn = Integer.valueOf(prn);\r
+ float floatsnr = Float.valueOf(snr);\r
+ if (floatsnr > 0) {\r
//排序取得最大3个SNR\r
get3MaxSnrSatellite(new ICLocation.GpsSatellitePriv(intprn, floatsnr));\r
runtime.getLocationInstance().numSatelliteList.add(new ICLocation.GpsSatellitePriv(intprn, floatsnr));\r
}\r
\r
runtime.getLocationInstance().set_adding_satlite_flag(false);\r
- if (maxPageCount==currentPage) {\r
+ if (maxPageCount == currentPage) {\r
//最后一页,打印搜星情况,并作一些判断。\r
- StringBuilder sb=new StringBuilder();\r
- sb.append("搜索"+searchCout+"次,搜索到卫星个数" + SatlitesCount+", [SNR>0] ="+ runtime.getLocationInstance().numSatelliteList.size());\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append("搜索" + searchCout + "次,搜索到卫星个数" + SatlitesCount + ", [SNR>0] =" + runtime.getLocationInstance().numSatelliteList.size());\r
sb.append(", Max 5 SNR [");\r
- for (int i=0;i< runtime.getLocationInstance().max3Satellite.size();i++){\r
- sb.append( runtime.getLocationInstance().max3Satellite.get(i).getSnr()+",");\r
+ for (int i = 0; i < runtime.getLocationInstance().max3Satellite.size(); i++) {\r
+ sb.append(runtime.getLocationInstance().max3Satellite.get(i).getSnr() + ",");\r
}\r
sb.append("]");\r
if (Config.LOG_TOFILE)\r
- FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",sb.toString());\r
- ICLogger.i( sb.toString());\r
+ FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb.toString());\r
+ ICLogger.i(sb.toString());\r
\r
// 卫星总数小于2 ,或者 snr小于20\r
- if ( runtime.getLocationInstance().numSatelliteList.size()< 3 && ( runtime.getLocationInstance().max3Satellite.size()>0?( runtime.getLocationInstance().max3Satellite.get(0).getSnr()<20?true:false) : true)){\r
+ if (runtime.getLocationInstance().numSatelliteList.size() < 3 && (runtime.getLocationInstance().max3Satellite.size() > 0 ? (runtime.getLocationInstance().max3Satellite.get(0).getSnr() < 20 ? true : false) : true)) {\r
noSignalCount++;\r
}\r
\r
\r
- StringBuilder sb2=new StringBuilder();\r
- if(!noStop) {\r
+ StringBuilder sb2 = new StringBuilder();\r
+ if (!noStop) {\r
if (searchCout > ICLocation.MAX_GPS_SEARCH_TIMEOUT) {\r
sb2.append(" 搜索" + searchCout + "次未定位,超过" + ICLocation.MAX_GPS_SEARCH_TIMEOUT + "限制退出GPS定位");\r
\r
stop(MSG_WHAT_GPS_NOSTAR);\r
}\r
}\r
- ICLogger.i( sb2.toString());\r
+ ICLogger.i(sb2.toString());\r
if (Config.LOG_TOFILE)\r
- FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",sb2.toString());\r
+ FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb2.toString());\r
\r
}\r
- }else if (nmeastr.startsWith("$GPGGA,")) {\r
+ } else if (nmeastr.startsWith("$GPGGA,")) {\r
\r
// GPGGA编辑\r
//(定位信息)\r
// 字段14:差分站ID号0000 - 1023(前导位数不足则补0,如果不是差分定位将为空)\r
// 字段15:校验值($与*之间的数异或后的值)\r
\r
- String tmplist[]=nmeastr.split(",");\r
- String utctime=tmplist[1];\r
- String Lat=tmplist[2];\r
- String lon=tmplist[4];\r
- String fixed=tmplist[6];\r
- String usedStarts=tmplist[7];\r
- String hdop=tmplist[8];\r
+ String tmplist[] = nmeastr.split(",");\r
+ String utctime = tmplist[1];\r
+ String Lat = tmplist[2];\r
+ String lon = tmplist[4];\r
+ String fixed = tmplist[6];\r
+ String usedStarts = tmplist[7];\r
+ String hdop = tmplist[8];\r
\r
\r
- if ( (fixed.trim().equals("1"))||(fixed.trim().equals("2"))||(fixed.trim().equals("6"))){\r
+ if ((fixed.trim().equals("1")) || (fixed.trim().equals("2")) || (fixed.trim().equals("6"))) {\r
\r
\r
- // 转换GPS坐标为度,以便在各种应用中可以方便查找。\r
- latitude=Double.valueOf(Lat);\r
- longitude=Double.valueOf(lon);\r
- // 转换单位,从分转换到度\r
+ // 转换GPS坐标为度,以便在各种应用中可以方便查找。\r
+ latitude = Double.valueOf(Lat);\r
+ longitude = Double.valueOf(lon);\r
+ // 转换单位,从分转换到度\r
\r
- double intdu= (int)(longitude /100f); //小数转换到分为单位\r
- double du=(longitude - intdu*100)/60f;\r
- double last= intdu+du;\r
- longitude =last;\r
- intdu= (int)(latitude /100f); //小数转换到分为单位\r
- du=(latitude - intdu*100)/60f;\r
- last= intdu+du;\r
- latitude=last;\r
+ double intdu = (int) (longitude / 100f); //小数转换到分为单位\r
+ double du = (longitude - intdu * 100) / 60f;\r
+ double last = intdu + du;\r
+ longitude = last;\r
+ intdu = (int) (latitude / 100f); //小数转换到分为单位\r
+ du = (latitude - intdu * 100) / 60f;\r
+ last = intdu + du;\r
+ latitude = last;\r
\r
- // 经纬度 保留4位小数点\r
- DecimalFormat df = new DecimalFormat("#.000000");\r
- String strLatitude = df.format(latitude);\r
- String strLongitude = df.format(longitude);\r
+ // 经纬度 保留4位小数点\r
+ DecimalFormat df = new DecimalFormat("#.000000");\r
+ String strLatitude = df.format(latitude);\r
+ String strLongitude = df.format(longitude);\r
\r
//定位\r
- StringBuilder sb=new StringBuilder();\r
- sb.append("GPGGA, location time= " + TimeUtil.getLocalTime() + ", FixedCount=" + locationFixedCount + ", GPSTime="+utctime+", Lat="+Lat+" ("+strLatitude+"), Lon="+lon+" ("+strLongitude+"), fixed="+fixed+", hdop="+hdop+", usedStarts="+usedStarts);\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append("GPGGA, location time= " + TimeUtil.getLocalTime() + ", FixedCount=" + locationFixedCount + ", GPSTime=" + utctime + ", Lat=" + Lat + " (" + strLatitude + "), Lon=" + lon + " (" + strLongitude + "), fixed=" + fixed + ", hdop=" + hdop + ", usedStarts=" + usedStarts);\r
ICLogger.i(sb.toString());\r
if (Config.LOG_TOFILE)\r
FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb.toString());\r
//定位了,\r
- if (hdop!=null&& hdop.trim().length()>0 && Float.valueOf(hdop)<ICLocation.MAX_HDOP) {\r
- locationFixedCount++;\r
- }else{\r
- ICLogger.i("HDOP is larger than "+ICLocation.MAX_HDOP+" , skip this location!");\r
- if (Config.LOG_TOFILE)\r
- FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "HDOP is larger than "+ICLocation.MAX_HDOP+" , skip this location!");\r
- }\r
- if (locationFixedCount > MaxFixedTimes) {\r
+ if (hdop != null && hdop.trim().length() > 0 && Float.valueOf(hdop) < ICLocation.MAX_HDOP) {\r
+ locationFixedCount++;\r
+ } else {\r
+ ICLogger.i("HDOP is larger than " + ICLocation.MAX_HDOP + " , skip this location!");\r
+ if (Config.LOG_TOFILE)\r
+ FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "HDOP is larger than " + ICLocation.MAX_HDOP + " , skip this location!");\r
+ }\r
+ if (locationFixedCount > MaxFixedTimes) {\r
/*\r
只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
延迟MaxFixedTimes秒后才设置runtime的定位标志,以便稳定坐标值。\r
*/\r
- runtime.getLocationInstance().setLocation(Lat,lon);\r
- runtime.getLocationInstance().setUsedStarts(Integer.valueOf(usedStarts.trim()));\r
- runtime.getLocationInstance().setHod(Float.valueOf(hdop.trim()));\r
- runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED);\r
- ICLogger.i("定位"+locationFixedCount+"次 > "+MaxFixedTimes+", set LOCATION_FIXED ");\r
- if (Config.LOG_TOFILE)\r
- FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "定位"+locationFixedCount+"次 > "+MaxFixedTimes+", set LOCATION_FIXED ");\r
- if (!noStop) {\r
- stopListen();\r
- }\r
+ runtime.getLocationInstance().setLocation(Lat, lon);\r
+ runtime.getLocationInstance().setUsedStarts(Integer.valueOf(usedStarts.trim()));\r
+ runtime.getLocationInstance().setHod(Float.valueOf(hdop.trim()));\r
+ runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED);\r
+ ICLogger.i("定位" + locationFixedCount + "次 > " + MaxFixedTimes + ", set LOCATION_FIXED ");\r
+ if (Config.LOG_TOFILE)\r
+ FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "定位" + locationFixedCount + "次 > " + MaxFixedTimes + ", set LOCATION_FIXED ");\r
+ if (!noStop) {\r
+ stopListen();\r
}\r
- gps_status.locating_status=1; //fixed\r
- }else{\r
- gps_status.locating_status=0; //notfixed\r
+ }\r
+ gps_status.locating_status = 1; //fixed\r
+ } else {\r
+ gps_status.locating_status = 0; //notfixed\r
}\r
- gps_status.hdop=Float.valueOf(hdop.trim());\r
- gps_status.used_gps_numbs=Integer.valueOf(usedStarts.trim());\r
+ gps_status.hdop = Float.valueOf(hdop.trim());\r
+ gps_status.used_gps_numbs = Integer.valueOf(usedStarts.trim());\r
\r
\r
- }else if (nmeastr.startsWith("$GPGSA,")) {\r
+ } else if (nmeastr.startsWith("$GPGSA,")) {\r
\r
// GPGSA编辑\r
//( 当前卫星信息)\r
// }\r
}\r
}\r
- \r
- public void onProviderDisabled(String paramString) {}\r
- \r
- public void onProviderEnabled(String paramString) {}\r
+\r
+ public void onProviderDisabled(String paramString) {\r
+ }\r
+\r
+ public void onProviderEnabled(String paramString) {\r
+ }\r
\r
@Override\r
public void onLocationChanged(Location location) {\r
\r
}\r
\r
- public void onStatusChanged(String paramString, int paramInt, Bundle paramBundle) {}\r
+ public void onStatusChanged(String paramString, int paramInt, Bundle paramBundle) {\r
+ }\r
\r
- public boolean gpsColdStart(){\r
+ public boolean gpsColdStart() {\r
//冷启动\r
Bundle bundle = null;\r
locationManager.sendExtraCommand("gps", "force_xtra_injection", bundle); //command\r
\r
}\r
\r
- public boolean gpsWormStart(){\r
+ public boolean gpsWormStart() {\r
\r
//温启动\r
Bundle bundleWarm = new Bundle();\r
return b2;\r
}\r
\r
- public boolean gpsHotStart(){\r
+ public boolean gpsHotStart() {\r
//热启动\r
Bundle bundleHot = new Bundle();\r
bundleHot.putBoolean("almanac", true);\r
}\r
\r
\r
- private final int MSG_WHAT_GPS_FIXED=300;\r
- private final int MSG_WHAT_GPS_TIMEOUT=100;\r
- private final int MSG_WHAT_GPS_NOSTAR=200;\r
- private final int MSG_WHAT_GPS_FIXED_NO_STOP=400;\r
+ private final int MSG_WHAT_GPS_FIXED = 300;\r
+ private final int MSG_WHAT_GPS_TIMEOUT = 100;\r
+ private final int MSG_WHAT_GPS_NOSTAR = 200;\r
+ private final int MSG_WHAT_GPS_FIXED_NO_STOP = 400;\r
\r
Handler temHandler = new Handler(new Handler.Callback() {\r
@Override\r
public boolean handleMessage(Message message) {\r
\r
- if( message.what== MSG_WHAT_GPS_TIMEOUT|| message.what==MSG_WHAT_GPS_NOSTAR){\r
- //no start\r
- //do nothing\r
+ if (message.what == MSG_WHAT_GPS_TIMEOUT || message.what == MSG_WHAT_GPS_NOSTAR) {\r
+ //no start\r
+ //do nothing\r
\r
- }\r
- else if (message.what==MSG_WHAT_GPS_FIXED){\r
+ } else if (message.what == MSG_WHAT_GPS_FIXED) {\r
//fixed\r
/*\r
只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
\r
}\r
\r
- if (!noStop){\r
- ICLogger.i("handleMessage MSG_WHAT_GPS_TIMEOUT/ MSG_WHAT_GPS_NOSTAR/ MSG_WHAT_GPS_FIXED "+message.what);\r
+ if (!noStop) {\r
+ ICLogger.i("handleMessage MSG_WHAT_GPS_TIMEOUT/ MSG_WHAT_GPS_NOSTAR/ MSG_WHAT_GPS_FIXED " + message.what);\r
\r
stopListen();\r
}\r
return true;\r
}\r
});\r
- private void get3MaxSnrSatellite(ICLocation.GpsSatellitePriv gst){\r
+\r
+ private void get3MaxSnrSatellite(ICLocation.GpsSatellitePriv gst) {\r
\r
float snr = gst.getSnr();\r
- for (int k=0;k< runtime.getLocationInstance().max3Satellite.size();k++) {\r
- if( runtime.getLocationInstance().max3Satellite.get(k).getPrn()==gst.getPrn())\r
+ for (int k = 0; k < runtime.getLocationInstance().max3Satellite.size(); k++) {\r
+ if (runtime.getLocationInstance().max3Satellite.get(k).getPrn() == gst.getPrn())\r
runtime.getLocationInstance().max3Satellite.remove(k);\r
}\r
runtime.getLocationInstance().max3Satellite.add(gst);//先添加进来。\r
\r
//从大到小排序\r
- for(int i=0;i< runtime.getLocationInstance().max3Satellite.size();i++) {\r
- for (int j=i;j< runtime.getLocationInstance().max3Satellite.size();j++) {\r
- if ( runtime.getLocationInstance().max3Satellite.get(i).getSnr() < runtime.getLocationInstance().max3Satellite.get(j).getSnr()) {\r
- ICLocation.GpsSatellitePriv ts = runtime.getLocationInstance().max3Satellite.get(j);\r
+ for (int i = 0; i < runtime.getLocationInstance().max3Satellite.size(); i++) {\r
+ for (int j = i; j < runtime.getLocationInstance().max3Satellite.size(); j++) {\r
+ if (runtime.getLocationInstance().max3Satellite.get(i).getSnr() < runtime.getLocationInstance().max3Satellite.get(j).getSnr()) {\r
+ ICLocation.GpsSatellitePriv ts = runtime.getLocationInstance().max3Satellite.get(j);\r
runtime.getLocationInstance().max3Satellite.remove(j);\r
runtime.getLocationInstance().max3Satellite.add(i, ts);//大的放前面\r
}\r
}\r
}\r
- if ( runtime.getLocationInstance().max3Satellite.size()>5){ //超过三个,谁小就删掉\r
+ if (runtime.getLocationInstance().max3Satellite.size() > 5) { //超过三个,谁小就删掉\r
runtime.getLocationInstance().max3Satellite.remove(5);\r
}\r
\r
}\r
\r
//停止定位\r
- private void stop(int id){\r
+ private void stop(int id) {\r
\r
// 经纬度 保留6位小数点\r
// DecimalFormat df = new DecimalFormat("#.000000");\r
//发送停止消息\r
temHandler.sendEmptyMessage(id);\r
}\r
+\r
boolean isFrist = true;\r
\r
\r
\r
ICLogger.i("GPS StartListen with Provider " + provider);\r
\r
- if( Config.LOG_TOFILE) ICLogger.logToFile("GPS","GPS StartListen with Provider " + provider);\r
+ if (Config.LOG_TOFILE) ICLogger.logToFile("GPS", "GPS StartListen with Provider " + provider);\r
\r
this.locationManager.requestLocationUpdates(provider, 0L, 0.0F, this);\r
\r
longitude = 0;\r
latitude = 0;\r
searchCout = 0;\r
- locationFixedCount=0;\r
+ locationFixedCount = 0;\r
gpsMode = GPS_CURRENT_STATUS.GPS_LISTENING;\r
// locationManager.addGpsStatusListener(statusListener);//监听搜星状态\r
locationManager.addNmeaListener(this); //监听NMEA 协议数据。\r
\r
//做个热启动\r
return true;//gpsHotStart();\r
- }else{\r
+ } else {\r
ICLogger.i(" location listening, skip !");\r
- if( Config.LOG_TOFILE)ICLogger.logToFile("GPS"," location listening, skip !");\r
+ if (Config.LOG_TOFILE) ICLogger.logToFile("GPS", " location listening, skip !");\r
\r
return true;\r
}\r
}\r
- \r
+ public boolean isGpsOpening() {\r
+ return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);\r
+ }\r
\r
public void stopListen() {\r
this.locationManager.removeNmeaListener(this);\r