座標データ収集

45795 ワード

ublic class GPSDataCollectorService extends Service {     private static final String TAG = GPSDataCollectorService.class             .getSimpleName();     LocationManager locationManager;     LocationListener gpsLocationListener;     @Override     public IBinder onBind(Intent intent) {         return null;     }     @Override     public void onCreate() {         super.onCreate();         locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);         gpsLocationListener = new GPSLocationListener();         locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10 * 1000L, 0, gpsLocationListener);     }     @Override     public void onDestroy() {         super.onDestroy();         Log.i(TAG, "Service destroying");         locationManager.removeUpdates(gpsLocationListener);     }     private class GPSLocationListener implements LocationListener {         @Override         public void onLocationChanged(Location location) {             Log.d(TAG, "onLocationChanged: " + location.toString());         }         @Override         public void onStatusChanged(String provider, int status, Bundle extras) {             Log.d(TAG, "onStatusChanged: " + status);         }         @Override         public void onProviderEnabled(String provider) {             // TODO Auto-generated method stub         }         @Override         public void onProviderDisabled(String provider) {             // TODO Auto-generated method stub         }     } }