How do I find out if the GPS of an Android device is enabled

后端 未结 10 1558
暖寄归人
暖寄归人 2020-11-22 08:36

On an Android Cupcake (1.5) enabled device, how do I check and activate the GPS?

10条回答
  •  逝去的感伤
    2020-11-22 09:17

    Yes you can check below is the code:

    public boolean isGPSEnabled (Context mContext){
        LocationManager locationManager = (LocationManager)
                    mContext.getSystemService(Context.LOCATION_SERVICE);
        return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    }
    

提交回复
热议问题