Request permissions only on Android 6.0 or later

pull/3/head
Olga Miller 2017-01-07 17:02:42 +01:00
rodzic c08b6e7c4b
commit bd949f044b
1 zmienionych plików z 2 dodań i 4 usunięć

Wyświetl plik

@ -158,18 +158,16 @@ public class MainActivity extends AppCompatActivity {
&& ((ErrnoException) ex.getCause()).errno == OsConstants.EACCES;
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private boolean needsRequestReadPermission() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
return false;
String permission = Manifest.permission.READ_EXTERNAL_STORAGE;
int state = ContextCompat.checkSelfPermission(this, permission);
return state != PackageManager.PERMISSION_GRANTED;
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private boolean needsRequestWritePermission() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
return false;
String permission = Manifest.permission.WRITE_EXTERNAL_STORAGE;
int state = ContextCompat.checkSelfPermission(this, permission);