{"_id":"58aad9dd8f862f250076fa01","parentDoc":null,"category":{"_id":"58aad9dd8f862f250076f9f8","project":"54aa7f773b56130b0056c86e","version":"58aad9dd8f862f250076f9f4","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-01-05T12:44:00.338Z","from_sync":false,"order":4,"slug":"android-sdk","title":"Android SDK"},"user":"54aa7f3f9bb00c0b00cb899b","project":"54aa7f773b56130b0056c86e","__v":0,"version":{"_id":"58aad9dd8f862f250076f9f4","project":"54aa7f773b56130b0056c86e","__v":2,"createdAt":"2017-02-20T11:58:21.765Z","releaseDate":"2017-02-20T11:58:21.765Z","categories":["58aad9dd8f862f250076f9f5","58aad9dd8f862f250076f9f6","58aad9dd8f862f250076f9f7","58aad9dd8f862f250076f9f8","58aad9dd8f862f250076f9f9","58aad9dd8f862f250076f9fa","58aad9dd8f862f250076f9fb","58ac26b3d460ce2500185d26"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":false,"codename":"Locate","version_clean":"6.0.0","version":"6.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-16T09:53:12.803Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":5,"body":"[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"Android Permissions\",\n  \"body\": \"Please note that these permissions are required for all users on versions of Android above Android 6.\"\n}\n[/block]\nThe Locate SDK requires two permissions - Location and Storage.\n\nHere is an example how to ask the user for these permissions:\n\n1. Location Permission - required for beacon scans, geofencing and location updates. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"int permissionCheck = ContextCompat.checkSelfPermission(this,\\n                android.Manifest.permission.ACCESS_FINE_LOCATION);\\nif (permissionCheck != PackageManager.PERMISSION_GRANTED) {\\n    ActivityCompat.requestPermissions(this,\\n        new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, 1);\\n}\",\n      \"language\": \"java\",\n      \"name\": \"Location Permission\"\n    }\n  ]\n}\n[/block]\n2. Storage Permission - is needed only during development to store crashlogs on SD Card. Can be removed before releasing to appstore.\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"int permissionCheck = ContextCompat.checkSelfPermission(this,\\n                android.Manifest.permission.WRITE_EXTERNAL_STORAGE);\\nif (permissionCheck != PackageManager.PERMISSION_GRANTED) {\\n    ActivityCompat.requestPermissions(this,\\n        new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);\\n}\",\n      \"language\": \"java\",\n      \"name\": \"Storage Permission\"\n    }\n  ]\n}\n[/block]\nTo ask for both permissions at once:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"int permissionCheck = ContextCompat.checkSelfPermission(this,\\n                android.Manifest.permission.ACCESS_FINE_LOCATION);\\nint permissionCheck2 = ContextCompat.checkSelfPermission(this,\\n                android.Manifest.permission.WRITE_EXTERNAL_STORAGE);\\nif (permissionCheck != PackageManager.PERMISSION_GRANTED \\n    && permissionCheck2 != PackageManager.PERMISSION_GRANTED) {\\n            ActivityCompat.requestPermissions(this,\\n                    new String[]{\\n                      android.Manifest.permission.ACCESS_FINE_LOCATION,                 \\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tandroid.Manifest.permission.WRITE_EXTERNAL_STORAGE},\\n                      1);\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"android-6-permissions","type":"basic","title":"Android Permissions"}

Android Permissions


[block:callout] { "type": "success", "title": "Android Permissions", "body": "Please note that these permissions are required for all users on versions of Android above Android 6." } [/block] The Locate SDK requires two permissions - Location and Storage. Here is an example how to ask the user for these permissions: 1. Location Permission - required for beacon scans, geofencing and location updates. [block:code] { "codes": [ { "code": "int permissionCheck = ContextCompat.checkSelfPermission(this,\n android.Manifest.permission.ACCESS_FINE_LOCATION);\nif (permissionCheck != PackageManager.PERMISSION_GRANTED) {\n ActivityCompat.requestPermissions(this,\n new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, 1);\n}", "language": "java", "name": "Location Permission" } ] } [/block] 2. Storage Permission - is needed only during development to store crashlogs on SD Card. Can be removed before releasing to appstore. [block:code] { "codes": [ { "code": "int permissionCheck = ContextCompat.checkSelfPermission(this,\n android.Manifest.permission.WRITE_EXTERNAL_STORAGE);\nif (permissionCheck != PackageManager.PERMISSION_GRANTED) {\n ActivityCompat.requestPermissions(this,\n new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);\n}", "language": "java", "name": "Storage Permission" } ] } [/block] To ask for both permissions at once: [block:code] { "codes": [ { "code": "int permissionCheck = ContextCompat.checkSelfPermission(this,\n android.Manifest.permission.ACCESS_FINE_LOCATION);\nint permissionCheck2 = ContextCompat.checkSelfPermission(this,\n android.Manifest.permission.WRITE_EXTERNAL_STORAGE);\nif (permissionCheck != PackageManager.PERMISSION_GRANTED \n && permissionCheck2 != PackageManager.PERMISSION_GRANTED) {\n ActivityCompat.requestPermissions(this,\n new String[]{\n android.Manifest.permission.ACCESS_FINE_LOCATION, \t\t\t\t\t\t\t\t\t\t\tandroid.Manifest.permission.WRITE_EXTERNAL_STORAGE},\n 1);\n}", "language": "java" } ] } [/block]