Hi,
Below is a short script I wrote to obtain the location of the phone using the
embedded GPS device.
...
LocationManager locationManager;
locationManager =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location =
locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
updateWithNewLocation(location);
}
private void updateWithNewLocation(Location location)
{
TextView myLocation;
myLocation = (TextView)findViewById(R.id.myLocation);
if (location != null)
{
double lat = location.getLatitude();
double lng = location.getLongitude();
myLocation.setText("My Current Position is \n Lat:" +lat+"\n Long:"+lng
);
} else
{
myLocation.setText("My Location Could NOT Be Found");
}
}
...
I have all the permits in the Manifest file at the right places:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
(PS. I know that I don't need COARSE_LOCATION and INTERNET access in this
particular case)
Anyway, the code seems to work fine, but locationManager always returns null
even though I tried to send mock location data to the Android Emulator via the
DDMS application using the "Manual Location" tab. Whatever I send seems to be
ignored. I also tried establishing a telnet connecton to the emulator and using
the command "geo fix lat long". I did get an OK message yet, the emulator still
returns null to my request.
Any ideas about what might be the problem ?
Cheers,
Emre
_________________________________________________________________
Attention all humans. We are your photos. Free us.
http://go.microsoft.com/?linkid=9666047
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---