Android GoogleMaps myLocation Permission

后端 未结 5 1152
灰色年华
灰色年华 2021-01-17 16:25

With the more recent version of Android... you are supposed to check if the user has given you permission before you use their location info. I\'ve gone through the android

5条回答
  •  难免孤独
    2021-01-17 16:58

    Also, checking to see if you have the permissions and actually requesting it are two different things.

    As the android developer blog suggests you need to ask for permissions in a way like this:

    ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_RESULT_CODE);
    

    And then handle the result of the request by overriding onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults).

提交回复
热议问题