Debian Codegraph @

contrib/RideLogger/src/com/ridelogger/listners/Gps.java

raw
1 package com.ridelogger.listners;
2
3 import com.ridelogger.RideService;
4
5 import android.content.Context;
6 import android.location.Location;
7 import android.location.LocationListener;
8 import android.location.LocationManager;
9
10 import android.os.Bundle;
11
12 /**
13 * Gps
14 * @author henry
15 * Listen and log gps events
16 */
17 public class Gps extends Base<Gps>
18 {
19 public Gps(RideService mContext)
20 {
21 super(mContext);
22
23 LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
24
25 //listen to gps events and log them
26 LocationListener locationListener = new LocationListener() {
27 public void onLocationChanged(Location location) {
28 int[] keys = {
29 RideService.ALTITUDE,
30 RideService.KPH,
31 RideService.bearing,
32 RideService.gpsa,
33 RideService.LAT,
34 RideService.LON
35 };
36
37 float[] values = {
38 (float) location.getAltitude(),
39 location.getSpeed(),
40 location.getBearing(),
41 location.getAccuracy(),
42 (float) location.getLatitude(),
43 (float) location.getLongitude()
44 };
45
46 alterCurrentData(keys, values);
47 }
48
49 @Override
50 public void onStatusChanged(String provider, int status, Bundle extras) {}
51
52 @Override
53 public void onProviderEnabled(String provider) {}
54
55 @Override
56 public void onProviderDisabled(String provider) {}
57 };
58
59 locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
60 }
61 }