You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Toast.makeText(this, "Einige Berechtigungen wurden verweigert. Die App benötigt Zugriff auf Medien, um Screenshots zu verarbeiten.", Toast.LENGTH_LONG).show()
53
+
54
+
// If MANAGE_EXTERNAL_STORAGE is needed (for Android 11+)
55
+
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.R) {
56
+
requestManageExternalStoragePermission()
57
+
}
58
+
}
59
+
}
60
+
36
61
overridefunonCreate(savedInstanceState:Bundle?) {
37
62
super.onCreate(savedInstanceState)
38
63
64
+
// Check and request permissions
65
+
checkAndRequestPermissions()
66
+
39
67
setContent {
40
68
GenerativeAISample {
41
69
// A surface container using the 'background' color from the theme
@@ -65,4 +93,49 @@ class MainActivity : ComponentActivity() {
65
93
}
66
94
}
67
95
}
96
+
97
+
privatefuncheckAndRequestPermissions() {
98
+
val permissionsToRequest = mutableListOf<String>()
99
+
100
+
// Check which permissions we need to request
101
+
for (permission in requiredPermissions) {
102
+
if (ContextCompat.checkSelfPermission(this, permission) !=PackageManager.PERMISSION_GRANTED) {
0 commit comments