/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/LocationLookup.java
ViewVC logotype

Diff of /android/TrainInfo/src/dk/thoerup/traininfo/LocationLookup.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1208 by torben, Sat Dec 25 21:22:44 2010 UTC revision 1446 by torben, Wed May 4 20:25:15 2011 UTC
# Line 1  Line 1 
1  package dk.thoerup.traininfo;  package dk.thoerup.traininfo;
2    
 import java.util.List;  
3    
4  import android.content.Context;  import android.content.Context;
5    import android.content.SharedPreferences;
6  import android.location.GpsSatellite;  import android.location.GpsSatellite;
7  import android.location.GpsStatus;  import android.location.GpsStatus;
8  import android.location.Location;  import android.location.Location;
9  import android.location.LocationListener;  import android.location.LocationListener;
10  import android.location.LocationManager;  import android.location.LocationManager;
11  import android.os.Bundle;  import android.os.Bundle;
12    import android.preference.PreferenceManager;
13  import android.util.Log;  import android.util.Log;
14    
15    
# Line 76  public class LocationLookup implements L Line 77  public class LocationLookup implements L
77                  satCount = 0;                  satCount = 0;
78                                    
79                  startTime = android.os.SystemClock.elapsedRealtime();                  startTime = android.os.SystemClock.elapsedRealtime();
   
                 List<String> providers = locManager.getProviders(true);          
80                                    
81                  if (providers.size() > 0) {                  boolean hasProvider = false;
82                          for(String provider : providers) {                  
83                                  Log.i("Provider", ""+provider);                  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(cntx);
84                                  if (provider.equalsIgnoreCase("gps")) {                  String networkPref = prefs.getString("location", "GPS"); //default value is gps
85                                          locManager.addGpsStatusListener(this);                  
86                                          hasGps = true;                                                    if (networkPref.equals("GPS")) {
87                                  }                          if (locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
88                                    locManager.addGpsStatusListener(this);
89                                  locManager.requestLocationUpdates(provider, 0, 0, this);                                  locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
90                                    
91                                    hasGps = true;
92                                    hasProvider = true;
93                          }                          }
94                  } else {                  }
95                    
96                    if (locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
97                            locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
98                            hasProvider = true;                    
99                    }
100                    
101                            
102                    if (hasProvider == false) {
103                          // message that no suitable provider was found                          // message that no suitable provider was found
104                          //hndl.sendEmptyMessage(StationList.NOPROVIDER);                          //hndl.sendEmptyMessage(StationList.NOPROVIDER);
105                          state = LookupStates.NOPROVIDER;                          state = LookupStates.NOPROVIDER;

Legend:
Removed from v.1208  
changed lines
  Added in v.1446

  ViewVC Help
Powered by ViewVC 1.1.20