Detecting GPS on/off switch in Android phones

后端 未结 4 899
心在旅途
心在旅途 2020-11-30 01:20

I would like to detect when the user changes the GPS settings on or off for an Android phone. Meaning when user switches GPS sattelite on/off or detection via access points

4条回答
  •  旧巷少年郎
    2020-11-30 01:58

    Impement android.location.LocationListener, there you have two functions

    public void onProviderEnabled(String provider);
    public void onProviderDisabled(String provider);
    

    Using this you can find out when the requested provider is turned on or off

提交回复
热议问题