Android Question Set or detect if network location option is enabled.

JoanRPM

Active Member
Licensed User
Longtime User
I have an application to find the location via mobiles and wifi networks. I use "LocationManager" for this.
Some users do not have the option enabled in location services to find networks. Without this option enabled the program is not able to determine the location.
Is there any way to enable it from B4A? or at least to know that it is not enabled?

Thank you.
 

warwound

Expert
Licensed User
Longtime User
I'm sure this has recently been talked about in another thread but can't find that thread now.

Although you cannot enable this setting you can find which location providers are currently enabled by using the Phone library:

B4X:
Dim Phone1 As Phone
Dim LocationProvidersAllowed As String

LocationProvidersAllowed = Phone1.GetSettings("location_providers_allowed")
Log(LocationProvidersAllowed)

' LocationProvidersAllowed will be a comma separated list such as gps or network,gps

Martin.
 
Upvote 0

metrick

Active Member
Licensed User
Longtime User
I'm sure this has recently been talked about in another thread but can't find that thread now.

Although you cannot enable this setting you can find which location providers are currently enabled by using the Phone library:

B4X:
Dim Phone1 As Phone
Dim LocationProvidersAllowed As String

LocationProvidersAllowed = Phone1.GetSettings("location_providers_allowed")
Log(LocationProvidersAllowed)

' LocationProvidersAllowed will be a comma separated list such as gps or network,gps

Martin.

warwound, all I got from the above code are true repeat on my LG-G2.
 
Upvote 0

JoanRPM

Active Member
Licensed User
Longtime User
Thank you all.

In my phone answers: gps, network.
At least we can know if it is enabled or not.
Time ago, I tested the Toogle library and did not work very well.

Greetings.
 
Upvote 0
Top