From 6914ed552770a90db881e3c350b497c37aac2688 Mon Sep 17 00:00:00 2001 From: Denis Nek Date: Thu, 1 Apr 2021 23:18:37 -0700 Subject: [PATCH] Request camera pemission --- .idea/misc.xml | 1 + app/src/main/AndroidManifest.xml | 2 +- .../java/com/nekdenis/camera/MainActivity.kt | 42 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 75b0ad7..f0830ab 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,6 +5,7 @@ + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0daf2b4..c6d94ce 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ - + , + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + if (requestCode == 0) { + if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { + initView() + } else { + Toast.makeText(this, "camera permission denied", Toast.LENGTH_LONG).show() + } + } + } + + private fun initView() { setContent { CameraComposeWorkshopTheme { // A surface container using the 'background' color from the theme @@ -24,6 +65,7 @@ class MainActivity : ComponentActivity() { } } + @Composable fun Greeting(name: String) { Text(text = "Hello $name!")