I am developing an application which uses the current location of the
user to do some operations. i have used LocationManager and
LocationListener to receive the latitude and longitude values in
onLocationChanged() method. it is perfectly working when i am testing
using emulator control in eclipse. when its accessing from the real
device its not functioning properly. its will give 0, 0 for latitude
ad longitude.
Here is my code which used to get the current location.
public GeoLocationManger(Activity activity) {
LocationManager locationManager = (LocationManager) activity
.getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
List providers = locationManager.getProviders(criteria,true);
if(providers != null && providers.size() >0){
LocationProvider pro =locationManager.getProvider(providers.get
(0).toString());
locationManager.requestLocationUpdates(pro.getName(), 0, 0, this);
}
else
{
Messages.displayMessageOnUI(GasBuddyConstants.INFO,
"GPS Not Enabled – Update your settings.",
activity);
}
}
public void onLocationChanged(Location location) {
this.latitude = location.getLatitude();
this.longitude = location.getLongitude();
}
/*code*/I am developing an application which uses the current location of the
user to do some operations. i have used LocationManager and
LocationListener to receive the latitude and longitude values in
onLocationChanged() method. it is perfectly working when i am testing
using emulator control in eclipse. when its accessing from the real
device its not functioning properly. its will give 0, 0 for latitude
ad longitude.
Here is my code which used to get the current location.
/*Code*/
public GeoLocationManger(Activity activity) {
LocationManager locationManager = (LocationManager) activity
.getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
List providers = locationManager.getProviders(criteria,true);
if(providers != null && providers.size() >0){
LocationProvider pro =locationManager.getProvider(providers.get
(0).toString());
locationManager.requestLocationUpdates(pro.getName(), 0, 0, this);
}
else
{
Messages.displayMessageOnUI(GasBuddyConstants.INFO,
"GPS Not Enabled – Update your settings.",
activity);
}
}
public void onLocationChanged(Location location) {
this.latitude = location.getLatitude();
this.longitude = location.getLongitude();
}
/*Code*/
is there any settings need to do with phone?
Please help me to resolve this.
Thanks in advance.
is there any settings need to do with phone?
Please help me to resolve this.
Thanks in advance.


