I am having a problem in getting GPS coordinates in 2.1.
The code i am using right now is working well in 1.6 but when i test this same apk in 1.6 device is showing null values
plz help me to find a way to work with 2.1 devices also
Here is my code...
public class GpsLocator {
private static String PROVIDER="gps";
private LocationManager myLocationManager=null;
public GpsLocator(Context context) {
myLocationManager=(LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
}
public void myOnresume() {
myLocationManager.requestLocationUpdates(PROVIDER, 0, 0, onLocationChange);
}
public void myonPause() {
myLocationManager.removeUpdates(onLocationChange);
}
public double getLatitude() {
Location loc=myLocationManager.getLastKnownLocation(PROVIDER);
if (loc==null) {
return(0);
}
return(loc.getLatitude());
}
public double getLongitude() {
Location loc=myLocationManager.getLastKnownLocation(PROVIDER);
if (loc==null) {
return(0);
}
return(loc.getLongitude());
}
LocationListener onLocationChange=new LocationListener() {
public void onLocationChanged(Location location) {
}
public void onProviderDisabled(String provider) {
// required for interface, not used
}
public void onProviderEnabled(String provider) {
// required for interface, not used
}
public void onStatusChanged(String provider, int status,Bundle extras) {
// required for interface, not used
}
};
}
in the manifest file i add permission for accessing file they are
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />