{"_id":"5671348860c8e70d006c96a1","parentDoc":null,"project":"54aa7f773b56130b0056c86e","__v":10,"version":{"_id":"55781fe25129590d003ff4f7","project":"54aa7f773b56130b0056c86e","forked_from":"54aa7f773b56130b0056c871","__v":6,"createdAt":"2015-06-10T11:30:42.700Z","releaseDate":"2015-06-10T11:30:42.700Z","categories":["55781fe35129590d003ff4f8","55781fe35129590d003ff4f9","55781fe35129590d003ff4fa","55781fe35129590d003ff4fb","55781fe35129590d003ff4fc","55781fe35129590d003ff4fd","55781fe35129590d003ff4fe","564bbc7e8841060d00abb2ee","565b66c446118c0d00dcb0bb","56898269f8dc340d00308c13","582318b23b961a0f009516a1","594a848c9f4771001a43c959"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Developers","version_clean":"2.0.0","version":"2.0"},"githubsync":"","user":"54aa7f3f9bb00c0b00cb899b","category":{"_id":"55781fe35129590d003ff4fc","pages":["55781fe45129590d003ff50d","55781fe45129590d003ff50e","55781fe45129590d003ff50f","55781fe45129590d003ff510","55781fe45129590d003ff511","55781fe45129590d003ff512","55781fe45129590d003ff513","55781fe45129590d003ff514","55781fe45129590d003ff515","55781fe45129590d003ff516","55f692b4fe4cce21005c78b0","55f7e91e60cc850d008a7a45","56333cab9c607719001b85e4","564462ed9ce94c0d00068ce9","564f54fa48a1df1700836653","565ee9e7413e06170093dde0","5661a8fdb401c70d00dde6fa","5671348860c8e70d006c96a1","568ce9707d3bf02300aa7734"],"version":"55781fe25129590d003ff4f7","__v":10,"project":"54aa7f773b56130b0056c86e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-01-05T12:44:00.338Z","from_sync":false,"order":4,"slug":"android-sdk","title":"Android SDK"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-16T09:53:12.803Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":6,"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 Pulsate 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 Pulsate 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]