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

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
chalasa
Posts: 18
Joined: November 25th, 2014, 9:37 am

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

Post 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.
sokiya
Posts: 15
Joined: January 15th, 2014, 5:48 am

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

Post 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.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

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

Post by Gregory Martin »

Won't this work?
if gps(open) = 0 then
    errmsg("Please turn on the GPS");
    reenter;
endif;
chalasa
Posts: 18
Joined: November 25th, 2014, 9:37 am

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

Post by chalasa »

Thanks Gregory,

It works.
Post Reply