Turning GPS Hardware On

I have compiled and installed an Android version of the following Corona SDK sample application (using CoronaSDK-2016.2949 with Sublime Text 3):

C:\Program Files (x86)\Corona Labs\Corona SDK\Sample Code\Hardware\GPS

When I install the application it requests the following during installation:

Do you want to install this application? It will get access to:

 

Privacy

approximate location (network-based)

precise location (GPS and network-based)

If the GPS is turned off on my phone before installing this application (settings -> Location = Off), this GPS sample application does not turn the GPS on, even after I agree to the above request.

Could someone please tell me how you programmatically turn on the GPS with Corona SDK?

Thank you.

Apps cannot turn GPS on and off on Android (or iOS for that matter) as that is a user controlled setting.  The permission that is being requested is for access to the GPS but if the user turns the GPS off in settings then getting such permission isn’t helpful.

Historically there have been unofficial workarounds for this but they mostly stopped working in Android 4 or required rooted phones and would probably result in an app being removed from the Play Store if reported to Google.

An Android application which does request permission and then turns the GPS hardware on is the Google maps app. If you turn your location off (Settings - Location = off) and then open up the Google maps app, it requests the following:

Use location?

 

This app wants to change your device settings:

 

Use GPS, Wi-Fi, and cell networks for location

 

NO YES

If it is a security restriction is this just a special case for the Google maps app? Why is it they can do it but no one else can? Because Android is their OS?

Apps cannot turn GPS on and off on Android (or iOS for that matter) as that is a user controlled setting.  The permission that is being requested is for access to the GPS but if the user turns the GPS off in settings then getting such permission isn’t helpful.

Historically there have been unofficial workarounds for this but they mostly stopped working in Android 4 or required rooted phones and would probably result in an app being removed from the Play Store if reported to Google.

An Android application which does request permission and then turns the GPS hardware on is the Google maps app. If you turn your location off (Settings - Location = off) and then open up the Google maps app, it requests the following:

Use location?

 

This app wants to change your device settings:

 

Use GPS, Wi-Fi, and cell networks for location

 

NO YES

If it is a security restriction is this just a special case for the Google maps app? Why is it they can do it but no one else can? Because Android is their OS?