How can I check if GPS is enabled before I try to use it

后端 未结 3 1875
鱼传尺愫
鱼传尺愫 2021-02-14 03:27

I have the following code and it\'s not good because sometimes GPS takes very long

How can I do the following:

  1. Check if GPS is enabled
  2. Use GPS if
3条回答
  •  既然无缘
    2021-02-14 04:16

    Just using this, you can check GPS availability

        LocationManager mlocManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);;
        boolean enabled = mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    

提交回复
热议问题