Android Question Location enable request in phone system settings

red30

Well-Known Member
Licensed User
Longtime User
How can I use B4A to request the inclusion of a location in the system settings? That is, you need to determine that it is turned off, and turn it on from the application itself. For example, do the same as this application does:
 

Attachments

  • Screenshot_20190202-210459.png
    96.9 KB · Views: 248
  • Screenshot_20190202-210508.png
    81.6 KB · Views: 234

DonManfred

Expert
Licensed User
Longtime User
Is it possible to do like in this video?
It is the user which Enable it. You see the click on the video. It does not happen programatically

The code can be found in the GPS Tutorial

 
Last edited:
Upvote 0

JohnC

Expert
Licensed User
Longtime User
To elaborate on what DonManfred is saying.

No android app can control the GPS settings due to google security reasons.

The only thing your app can do is check to see if it is OFF, and if so, it can notify the user that it needs to be turned on, then your app can run some special code (see above) to "open" the *devices* DEFAULT GPS settings page - Meaning that the "on/off" settings dialog that you see in your video is not part of that third-party app - that dialog is the *devices* default gps on/off dialog and your app can simply "jump" the user to that settings page so that the user doesn't have to manually go into their android system settings, then go into the "location" settings to get to this same page.
 
Upvote 0

wes58

Active Member
Licensed User
Longtime User
To elaborate on what DonManfred is saying.

No android app can control the GPS settings due to google security reasons.
This is not entirely true. Android system applications (applications which came as pre-installed on the phone) can do that - for example "Bixby Routines" on Samsung S10
 
Upvote 0

wes58

Active Member
Licensed User
Longtime User
You are right. Systemapps can do it.

But we (normal developers) are not allowed to install any Systemapp or make our own app a systemapp.
Yes, unfortunately.
Google says it is for security reason, but for me it is rubbish. Google restricts access to some permissions because it is easier for them to do it, rather than design a secure operating system.
They have created this elaborated permissions system, and say that the user has control over which permission to grant or deny for an application. But it is not true as well. For some of the Google application you can't disable some of the permissions. They just do what they feel like.
For me, if I write an application just for myself, why shouldn't I be able to do this, or use other permissions.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
A bit surprising however it is possible to let the user enable location services from your app: https://www.b4x.com/android/forum/threads/fusedlocationprovider-resolution-dialog.111652/

But isn't that dialog still generated by android and more or less acts as a mini version of the devices full GPS settings page so that it will allow the user to simply turn on GPS instead of showing all the other options that the full location settings page has?

And isn't that dialog being mandatorily (is that a word?) displayed by android so that it A) notifies the user and B) the user needs to approve this action so it will prevent any non-system app from turning on GPS "silently"?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…