Thanks for the reply Shailesh.

I tried the ACCESS_LOCATION_EXTRA_COMMANDS and your code of
lmanager.getLastKnownLocation(lmanager.getProviders(true).get(0))
but I'm still getting a null.

1. What are the values that you get for this location? (I mean the
coordinates)

2. Do you get the error for /etc/gps.conf when you start the emulator?
(or you could check if you have /etc/gps.conf using the adb shell)

Thanks for your help,
Gautam

On Oct 16, 1:49 am, "shailesh prakash" <[EMAIL PROTECTED]> wrote:
> Try
> <!-- why I add this I didn't remember -->
> <uses-permission
> android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>
>
> and see my MapActivity code its working on 1.0,
>
> private MyLocationOverlay mMyLocationOverlay;
>         @Override
>         public void onCreate(Bundle icicle)
>         {
>                 super.onCreate(icicle);
>                 setContentView(R.layout.main);
>                 kMapView = (MapView) findViewById(R.id.main_map);
>                 kMapCtrl = kMapView.getController();
>                 LocationManager lm = 
> (LocationManager)getSystemService(LOCATION_SERVICE);
>                 Location loc = 
> lm.getLastKnownLocation(lm.getProviders(true).get(0));
>                .........
>          }
>
> On Thu, Oct 16, 2008 at 10:21 AM, Gautam <[EMAIL PROTECTED]> wrote:
>
> > Hi All,
> > I'm trying to get the location using the
> > LocationManager.getLastKnownLocation("gps") method and am getting
> > null. Here is the problem in more detail:
>
> > When I start the emulator, I get the following gps errors in LogCat:
> > 10-16 04:15:29.006: ERROR/GpsLocationProvider(52): Could not open GPS
> > configuration file /etc/gps.conf
> > 10-16 04:15:29.006: ERROR/GpsLocationProvider(52):
> > java.io.FileNotFoundException: /etc/gps.conf
> > 10-16 04:15:29.006: ERROR/GpsLocationProvider(52):     at
> > org.apache.harmony.luni.platform.OSFileSystem.open(OSFileSystem.java:
> > 227)
> > 10-16 04:15:29.006: ERROR/GpsLocationProvider(52):     at
> > java.io.FileInputStream.<init>(FileInputStream.java:76)
> > 10-16 04:15:29.006: ERROR/GpsLocationProvider(52):     at
> > com.android.internal.location.GpsLocationProvider.<init>(GpsLocationProvider.java:
> > 179)
> > 10-16 04:15:29.006: ERROR/GpsLocationProvider(52):     at
> > com.android.server.LocationManagerService._loadProvidersNoSync(LocationManagerService.java:
> > 356)
> > 10-16 04:15:29.006: ERROR/GpsLocationProvider(52):     at
> > com.android.server.LocationManagerService.loadProvidersNoSync(LocationManagerService.java:
> > 340)
> > 10-16 04:15:29.006: ERROR/GpsLocationProvider(52):     at
> > com.android.server.LocationManagerService.loadProviders(LocationManagerService.java:
> > 333)
> > 10-16 04:15:29.006: ERROR/GpsLocationProvider(52):     at
> > com.android.server.LocationManagerService.<init>(LocationManagerService.java:
> > 447)
> > 10-16 04:15:29.006: ERROR/GpsLocationProvider(52):     at
> > com.android.server.ServerThread.run(SystemServer.java:230)
> > 10-16 04:15:29.017: ERROR/AndroidRuntime(52): Crash logging skipped,
> > no checkin service
> > 10-16 04:15:29.036: DEBUG/LocationManagerService(52): Found dir /data/
> > location/gps
> > 10-16 04:15:29.036: DEBUG/LocationManagerService(52): name = gps
> > 10-16 04:15:29.047: DEBUG/GpsLocationProvider(52): enable
> > 10-16 04:15:29.089: DEBUG/GpsLocationProvider(52): GpsEventThread
> > starting
>
> > I checked using "adb shell" and there is no file /etc/gps.conf but
> > seems that the "gps" provider does get enabled.
>
> > I wrote an activity, where the main logic is:
> > System.out.println("Providers found=" + lmanager.getAllProviders());
> > System.out.println("GPS Enabled=" +
> > lmanager.isProviderEnabled(LocationManager.GPS_PROVIDER));
> > System.out.println("Last Known Location=" +
> > lmanager.getLastKnownLocation(LocationManager.GPS_PROVIDER));
>
> > and have given the permissions for ACCESS_FINE_LOCATION and
> > ACCESS_MOCK_LOCATION in my manifest.xml
>
> > and here is the log when I run the code:
> > 10-16 04:22:33.316: DEBUG/LocationManagerService(52): getAllProviders
> > 10-16 04:22:33.327: INFO/System.out(230): Providers found=[gps]
> > 10-16 04:22:33.336: INFO/System.out(230): GPS Enabled=true
> > 10-16 04:22:33.336: INFO/System.out(230): Last Known Location=null
>
> > So, I get "gps" provider and it is enabled, but the last known
> > location I get is null.
>
> > I tried investigating further in the "adb shell" and got this:
> > # cd /data/location/gps
> > # ls
> > nmea
> > location
> > properties
>
> > # cat location
> > gps,1193789209,37.42238666666666666666,-122.096535,0,0,0
>
> > I am not trying to set my location (the setters for which have been
> > removed from Android 1.0), but just trying to retrieve it from the GPS
> > provider, so here I am wondering:
> > 1. Why am I getting null as the location?
> > 2. Say, we were to solve that issue, then would Android read the
> > location from the /data/location/gps/nmea or /data/location/gps/
> > location file? and where are we specifying that? Is this all due to
> > the missing /etc/gps.conf?
>
> > Thanks,
> > Gautam
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to