Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am get only Location is=0.0,Latitude=0.0 i am using emulator #2

Closed
RajeshRajendiran opened this issue Mar 19, 2015 · 2 comments
Closed

Comments

@RajeshRajendiran
Copy link

Hi
thanks for your Java class, After implementing code from your class i get Location is=0.0,Latitude=0.0
my code here
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.distance_find);
if (findComponentID()) {
getToolBar();
getDrawerList();
location = new SimpleLocation(this);
if (!location.hasLocationEnabled()) {
// ask the user to enable location access
SimpleLocation.openSettings(this);
}
imgBtnGetLocation.setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View v) {
getCurrentLocation();
}
});

    }

}

@OverRide
protected void onResume() {
super.onResume();
location.beginUpdates();
}

@Override
protected void onPause() {
    location.endUpdates();
    super.onPause();
}

private void getCurrentLocation() {

    final double latitude = location.getLatitude();
    final double longitude = location.getLongitude();
    Log.d("Testing", "Location is=" + "Latitude=" + latitude + "Longitude=" + longitude);
    txtViwMyLocation.setText("Latitude=" + latitude + "\n" + "Longitude=" + longitude);


}
@ocram
Copy link
Contributor

ocram commented Mar 19, 2015

Thanks for your question!

Please test the code on a real device to rule out the emulator as the cause for this problem.

Did you add one of the permissions to your app? Otherwise, your code looks okay.

On the emulator, you have to specifically enable location support and you have to set a faked location or mock location. If that's really what you want to do, you may read more here:
http://stackoverflow.com/questions/2279647/how-to-emulate-gps-location-in-the-android-emulator

@RajeshRajendiran
Copy link
Author

Thanks for your support dude,
I checked real device worked perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants