How do I tell if location detection is enabled in Android

P1x

I've a MapView (v2) in an activity, and I enabled the my location button through

getMap().getUiSettings().setMyLocationButtonEnabled(true);
getMap().setMyLocationEnabled(true);

If the user clicks on the button then usually the map is centered on its position.

But after that many users reported that the button wasn't working I realized that the button works only if the location option in the google settings is enabled. Unfortunately I couldn't find a way to check if that option is enabled or not, so I'm not even able to tell the user to enable it.

If the location setting is not enabled I'd like to show the user a dialogbox similar to the one that appers in the same situation in the Google Maps application. But I can't know if the that setting is enabled or not!

matiash

You can do this via the LocationManager. For example:

LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);

boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
boolean networkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I tell if location detection is enabled in Android

From Dev

How do I tell if Razor is enabled in my existing MVC project?

From Dev

How do I tell Resharper to look in a custom location for Partial views?

From Dev

How do I tell render the location of the views partial

From Dev

How can I tell whether PFS is enabled?

From Dev

How do I tell the TLS version in Android Volley

From Dev

How can I tell if the libcurl installed has asynchronous DNS enabled?

From Dev

How can I tell if PPP compression is enabled for modem?

From Dev

How do I programmatically enable the the "Use location?" message in Android?

From Dev

How do I place a button in an Android activity in a new location?

From Dev

How to update the android app when the Location toggle is enabled in Settings?

From Dev

How to tell if I'm actually in a symlink location from command line?

From Dev

How do I get these ports enabled?

From Dev

How do I get enabled repos?

From Dev

How to track if location services is enabled or not enabled? titanium

From Dev

how do I tell cgo not to compile a file?

From Java

How do I tell if an object is a Promise?

From Dev

How do I tell boto operation was successful?

From Dev

How do I tell the status of a Kinesis shard?

From Dev

How do I tell if zsh is running with privileges?

From Dev

How do I tell maven where is Tomcat?

From Dev

How do I tell robocopy to ignore timestamps?

From Dev

How do I tell boto operation was successful?

From Dev

How do I tell if the center of a div is in the viewport?

From Dev

How do I tell a compiler to "ignore" a class?

From Dev

How do I tell if a float is a whole number?

From Dev

How do I build Libgdx.so from source for Android with gdb tracing enabled?

From Dev

How do I check if Android GPS is still scanning or position is fixed? not just check if enabled

From Dev

How do I build Libgdx.so from source for Android with gdb tracing enabled?

Related Related

  1. 1

    How do I tell if location detection is enabled in Android

  2. 2

    How do I tell if Razor is enabled in my existing MVC project?

  3. 3

    How do I tell Resharper to look in a custom location for Partial views?

  4. 4

    How do I tell render the location of the views partial

  5. 5

    How can I tell whether PFS is enabled?

  6. 6

    How do I tell the TLS version in Android Volley

  7. 7

    How can I tell if the libcurl installed has asynchronous DNS enabled?

  8. 8

    How can I tell if PPP compression is enabled for modem?

  9. 9

    How do I programmatically enable the the "Use location?" message in Android?

  10. 10

    How do I place a button in an Android activity in a new location?

  11. 11

    How to update the android app when the Location toggle is enabled in Settings?

  12. 12

    How to tell if I'm actually in a symlink location from command line?

  13. 13

    How do I get these ports enabled?

  14. 14

    How do I get enabled repos?

  15. 15

    How to track if location services is enabled or not enabled? titanium

  16. 16

    how do I tell cgo not to compile a file?

  17. 17

    How do I tell if an object is a Promise?

  18. 18

    How do I tell boto operation was successful?

  19. 19

    How do I tell the status of a Kinesis shard?

  20. 20

    How do I tell if zsh is running with privileges?

  21. 21

    How do I tell maven where is Tomcat?

  22. 22

    How do I tell robocopy to ignore timestamps?

  23. 23

    How do I tell boto operation was successful?

  24. 24

    How do I tell if the center of a div is in the viewport?

  25. 25

    How do I tell a compiler to "ignore" a class?

  26. 26

    How do I tell if a float is a whole number?

  27. 27

    How do I build Libgdx.so from source for Android with gdb tracing enabled?

  28. 28

    How do I check if Android GPS is still scanning or position is fixed? not just check if enabled

  29. 29

    How do I build Libgdx.so from source for Android with gdb tracing enabled?

HotTag

Archive