> locationmanger = (LocationManager)getSystemService > (Context.LOCATION_SERVICE); > location =locationmanager.getLastKnownLocation("gps"); > Log.v(TAG,"location obj"+location); > > The Log shows null instead of location object
Correct. > I am using emulator to test my code ,I have written appropriate > permissions,i am using android1.5 , > I could not figure out the reason At the time you made the call to getLastKnownLocation(), there was no GPS fix (real or simulated). > In eclipse after switching to DDMS mode , Emulator Controls tabs shows > Location Controls. From here, we can view longitude/latitude > coordinates to the device.Is there any way to bring down those data > into my activity . Is this only way to get longitude and latitude when > test with emulator. Use requestLocationUpdates() to turn the GPS radio (or emulated equivalent) on. Then, some time later, use DDMS to send a longitude/latitude to the emulator. Your LocationListener's onLocationChange() method will be called with the Location corresponding to your fix. Be sure to eventually call removeUpdates() to turn off the location update calls. -- Mark Murphy (a Commons Guy) http://commonsware.com Android App Developer Books: http://commonsware.com/books.html --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---