package com.jqmobile.core.android.lbs.base;
public class GpsThread extends Thread implements Runnable {
// private LocationManager mLocationManager = null;
// private Location location = null;
// private String provider;
// private double longitude = 0.0;
// private double latitude = 0.0;
// private long time = 0;
// private boolean task = true;
// private static String TAG = "GPSTHREAD";
// private SharedPreferences loationSharedFile = null;
// private WriteFile wf = null;
// private Application app= null;
//
// public GpsThread( Application app,SharedPreferences loationSharedFile) {
// this.loationSharedFile = loationSharedFile;
// this.app = app;
// wf = new WriteFile(TAG + JqydDateUtil.getDateDayOne(new Date()));
// }
//
// private void updateWithNewLocation(Location slocation) {
// SharedPreferences.Editor editor = loationSharedFile.edit();
// if (slocation != null) {
// wf.writeToFile("GPS获取到位置,开始赋值--------------------------" + time);
// Log.i(TAG, "GPS获取到位置,开始赋值--------------------------");
// latitude = slocation.getLatitude();
// longitude = slocation.getLongitude();
// time = slocation.getTime();
// location = slocation;
//
// editor.putString("lat", latitude + "");
// editor.putString("lon", longitude + "");
// editor.putLong("time", time);
// editor.putInt("active", 1);
// editor.commit();
//
// } else {
//
// editor.putString("lat", "0.0");
// editor.putString("lon", "0.0");
// editor.putLong("time", time);
// editor.putInt("active", 0);
// editor.commit();
// latitude = 0.0;
// longitude = 0.0;
// time = 0;
// location = null;
// }
// }
//
// private LocationListener locationListener = new LocationListener() {
// // 底层获得的位置会通过这个接口上报给应用
// public void onLocationChanged(Location location) {
// System.out.println("onLocationChanged");
// }
//
// // Provider被disable时触发此函数,比如GPS被关闭
// public void onProviderDisabled(String provider) {
// System.out.println("onProviderDisabled");
// stopGspListener();
// }
//
// // Provider被enable时触发此函数,比如GPS被打开
// public void onProviderEnabled(String provider) {
// System.out.println("onProviderEnabled");
// updateWithNewLocation(location);
// }
//
// /*
// * 位置服务状态的变化通过这个接口上报 Provider的转态在可用、暂时不可用和无服务三个状态直接切换时触发此函数
// */
// public void onStatusChanged(String provider, int status, Bundle extras) {
// System.out.println("onStatusChanged");
// }
// };
//
// /**
// * 移出gps监听器
// */
// public void stopGspListener() {
// // System.out.println("stopGspListener:"+locationListener);
// task = false;
// if (locationListener != null) {
// if (mLocationManager != null) {
// mLocationManager.removeUpdates(locationListener);
// }
// locationListener = null;
// location = null;
// System.out.println("locationListener:" + locationListener);
// }
// }
//
// @SuppressWarnings("static-access")
// public void run() {
// Looper.prepare();
//
// Log.i(TAG, "*********启动gps调用线程,开始获取gps位置信息********");
// wf.writeToFile("*********启动gps调用线程,开始获取gps位置信息********");
// mLocationManager = (LocationManager) app
// .getSystemService(Context.LOCATION_SERVICE);// 此处实例化了 手机的本地位置服务
// // 的一个对象
// provider = mLocationManager.GPS_PROVIDER;// 获取provider对象
//
// Log.i(TAG, "*******************GPS*******************"
// + mLocationManager);
// wf.writeToFile("*******************GPS*******************"
// + mLocationManager);
// mLocationManager.requestLocationUpdates(provider, 1000, 1,// 设置location的更新频率
// locationListener);
// while (task) {
// location = mLocationManager.getLastKnownLocation(provider);// 获得location
// updateWithNewLocation(location); // 更新位置
// while (location == null) {
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// location = mLocationManager.getLastKnownLocation(provider);// 获得location
// updateWithNewLocation(location); // 更新位置
// }
// }
// Looper.loop();
// }
//
}