Sanaco
Sanaco

Reputation: 35

Prevent user to change GPS status Fused Location API

I'm using the Google API (Fuse Location Provider) to track a device's location but I need to prevent the user from disabling the GPS. I read a lot of answers but all I've found is: No, can't do, rooting the device or bug exploits. A friend just showed me a parental control app that accomplishes this without having to root the device. About user privacy, etc. The code will be used only in company's devices with the users being aware of this.

At least I need a way to detect if the GPS has been deactivated to notify the user, by the way I can't find any reference to this in the Google API.

Thanks a lot in advance.

Upvotes: 1

Views: 1422

Answers (1)

user4665496
user4665496

Reputation:

GpsStatus.Listener - Try reading this.

You can override the method onGpsStatusChanged:

@Override
abstract void onGpsStatusChanged(int event){
    if (event==GPS_EVENT_STOPPED){

        LocationManager mlocManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        boolean enabled = mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        if(!enabled){
        //toggle your notification
        }
    } 
}

Upvotes: 1

Related Questions