April 2017
Intermediate to advanced
242 pages
6h 10m
English
In addition to the manifest permissions, Android needs explicit runtime permissions for Bluetooth and Coarse Location. Irrespective of the application flow, these permissions should be asked at the start of the application lifetime. To get the coarse location permission, you can add:
if (this.checkSelfPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_CODE_COARSE_PERMISSION); }
The method checkSelfPermission confirms if the location permission is not already given. On the other hand, the REQUEST_CODE_COARSE_PERMISSIONis a static integer which can be caught by overriding onRequestPermissionResult() ...
Read now
Unlock full access