Reputation: 129
I am starting the location services intent in order to get the location updates from the user:
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivityForResult(intent,100);
I then try to check the resultCode
inside onActivityResult method(for now I'm simply toasting):
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
Toast.makeText(this, "Result Code: " + resultCode, Toast.LENGTH_SHORT).show();
}
I was expecting the resultCode
to show a different result if the user toggles the location on or off. However I only get 0 as the result.
What criteria should I use to get whether or not the GPS was enabled?
Upvotes: 0
Views: 27
Reputation: 1007554
I was expecting the resultCode to show a different result if the user toggles the location on or off.
The documentation does not say that you get a result from that Intent
.
What criteria should I use to get whether or not the GPS was enabled?
Use LocationManager
and isProviderEnabled()
to determine if your desired provider is enabled.
Upvotes: 2