Android M Error on api 22, and requestPermissions() method not found -
i'm working in api 22, want compile project in android m 6.0, have code:
declared @ top:
private static final string[] required_permissions = new string[]{"read_external_storage"}; private static final int request_permissions = (integer) null;
and on oncreate()
:
if(build.version.sdk_int >= build.version_codes.m) { linkedlist<string> missingpermissions = new linkedlist<>(); for(string p : required_permissions){ if(checkcallingorselfpermission(p) != packagemanager.permission_granted){ missingpermissions.add(p); } } if(!missingpermissions.isempty()){ string[] mparray = new string[missingpermissions.size()]; missingpermissions.toarray(mparray); requestpermissions(mparray, request_permissions); } }
i inspired here checking problem , in eclipse giving me error on build.version_codes.m
(m not found), , then, callback method requestpermissions(mparray, request_permissions)
isn't found too, suggestion?
if i'm working on api 22, , i'm compiling android 6.0 m. how can solve issue dangerous permissions read_external_storage
correctly on api 22?
as per documentation, build.version_codes.m
, requestpermissions()
added in api level 23.
since compiling api level 22, not exist.
to access apis introduced in api level 23, need compile api 23. cannot access these apis if continue compile api 22.
note compiling api 23 not affect way application behaves on devices, opens newer apis use on devices running @ least api 23.
if i'm working on api 22, , i'm compiling android 6.0 m, how can solve issue dangerous permissions read_external_storage correctly on api 22?
devices running api 22 continue use old install-time model permissions. nothing has changed devices running api 22 , below. devices running api 23 use new runtime permissions model.
Comments
Post a Comment