Android Studio (2.2.3
) warns me against a method I called that is annoted with @RequiresPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
.
I would be OK with such a warning, but in my case, it's non-sense: I am calling the method within onRequestPermissionsResult
where I check that the WRITE_EXTERNAL_STORAGE
permission has been indeed granted :
if (permissions[0].equals(Manifest.permission.WRITE_EXTERNAL_STORAGE) && grantResults[0] == PackageManager.PERMISSION_GRANTED)
CSVUtils.setup(); // -> is highlighted in red!!
So following the warning advice, I am using checkSelfPermission()
but then Android Studio tells me that this is SDK 23 while I am targeting SDK 21 as minimum while I am in a method that could only be called in SDK 23 or newer. This really defeats the purpose, because I have all the code made to check the permission if user is running SDK 23 or newer, so why should I have to do more check ?
In any case, this is not really a problem, just that I don't like being warned this way when I don't need to annotate my methods with @RequirePermission
... what can I do ?
Add this annotation above the method to avoid warning
@SuppressWarnings({"MissingPermission"})