ask for notification and not for write permissions on Android 13

android
Ahmet Inan 2023-07-05 09:31:17 +02:00
rodzic 23f3c6de02
commit 58eb1be3e4
1 zmienionych plików z 7 dodań i 2 usunięć

Wyświetl plik

@ -238,8 +238,13 @@ public class MainActivity extends AppCompatActivity {
List<String> permissions = new ArrayList<>();
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED)
permissions.add(Manifest.permission.RECORD_AUDIO);
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
} else {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED)
permissions.add(Manifest.permission.POST_NOTIFICATIONS);
}
if (permissions.isEmpty())
return true;
ActivityCompat.requestPermissions(this, permissions.toArray(new String[0]), permissionsID);