Page 1 of 1

How to check if GPS is on, on Android phone before running GPS Function

Posted: May 23rd, 2018, 7:25 pm
by chalasa
Hallo,

I realized that to run the GPS function, the GPS android option has to be set to on. Can anyone share with me a code that will first check if the GPS is on, on the mobile phone before running the GPS function. If the GPS is not on then it should notify the enumerator to put on the GPS on the phone.

Kindly help.

Re: How to check if GPS is on, on Android phone before running GPS Function

Posted: May 24th, 2018, 7:16 am
by sokiya
Could you try something like

if execsystem("app:com.android.gps") <> 1 then
errmsg("Unable to launch gps.");
endif;

where com.android.gps is the package name of the application that you are trying to launch.

Re: How to check if GPS is on, on Android phone before running GPS Function

Posted: May 24th, 2018, 9:34 am
by Gregory Martin
Won't this work?
if gps(open) = 0 then
    errmsg("Please turn on the GPS");
    reenter;
endif;

Re: How to check if GPS is on, on Android phone before running GPS Function

Posted: May 24th, 2018, 4:26 pm
by chalasa
Thanks Gregory,

It works.