What permission is required to access the camera on Android?
The android.permission.CAMERA permission must be declared in the AndroidManifest.xml file and requested at runtime for Android 6.0 and above.
Click to reveal answer
beginner
How do you launch the camera app to take a photo using an Intent in Kotlin?
Use an Intent with action MediaStore.ACTION_IMAGE_CAPTURE and start it with startActivityForResult or the modern registerForActivityResult API.
Click to reveal answer
intermediate
What is the purpose of registerForActivityResult in camera access?
It replaces startActivityForResult to handle the result of the camera app in a cleaner, lifecycle-aware way.
Click to reveal answer
intermediate
Why do you need to create a file URI before launching the camera Intent?
To save the captured photo, you provide a file URI where the camera app stores the image. This avoids getting only a thumbnail and allows full-size photo saving.
Click to reveal answer
advanced
What is the role of FileProvider in camera access?
FileProvider securely shares file URIs with other apps, like the camera app, avoiding exposing file paths directly.
Click to reveal answer
Which permission must be requested at runtime to use the camera on Android 6.0+?
Aandroid.permission.CAMERA
Bandroid.permission.INTERNET
Candroid.permission.ACCESS_FINE_LOCATION
Dandroid.permission.READ_CONTACTS
✗ Incorrect
The CAMERA permission is required to access the device camera and must be requested at runtime starting from Android 6.0.
What Intent action is used to open the camera app for capturing a photo?
AIntent.ACTION_SEND
BIntent.ACTION_VIEW
CMediaStore.ACTION_IMAGE_CAPTURE
DMediaStore.ACTION_VIDEO_CAPTURE
✗ Incorrect
MediaStore.ACTION_IMAGE_CAPTURE launches the camera app to take a photo.
Which API is recommended for receiving results from the camera Intent in modern Android development?
AstartActivityForResult
BonActivityResult
CstartService
DregisterForActivityResult
✗ Incorrect
registerForActivityResult is the modern, lifecycle-aware API to handle activity results.
Why is FileProvider used when sharing a photo file URI with the camera app?
ATo compress the image
BTo securely share file URIs without exposing file paths
CTo encrypt the photo
DTo upload the photo to cloud
✗ Incorrect
FileProvider securely shares file URIs with other apps, preventing direct file path exposure.
What happens if you do not provide a file URI when launching the camera Intent?
AYou get only a small thumbnail image
BThe camera app records video instead
CThe photo is saved automatically in gallery
DThe camera app crashes
✗ Incorrect
Without a file URI, the camera returns only a small thumbnail image in the Intent result.
Explain the steps to capture a photo using the camera in an Android app with Kotlin.
Think about permissions, file storage, Intent, and result handling.
You got /5 concepts.
Describe why FileProvider is important when working with camera photo files on Android.
Consider Android's file access security model.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of using MediaStore.ACTION_IMAGE_CAPTURE in an Android app?
easy
A. To open the device camera to take a photo
B. To open the device gallery to select a photo
C. To record audio using the microphone
D. To access device location services
Solution
Step 1: Understand the intent action
MediaStore.ACTION_IMAGE_CAPTURE is a predefined intent action to launch the camera app for capturing images.
Step 2: Identify the purpose in the app
This intent opens the camera so the user can take a photo, which the app can then receive.
Final Answer:
To open the device camera to take a photo -> Option A
Quick Check:
Camera intent = open camera [OK]
Hint: Remember: ACTION_IMAGE_CAPTURE means open camera [OK]
Common Mistakes:
Confusing camera intent with gallery intent
Thinking it records audio
Assuming it accesses location
2. Which of the following is the correct Kotlin syntax to start the camera intent for result in an Activity?
easy
A. startActivityForResult(Intent(MediaStore.ACTION_IMAGE_CAPTURE), REQUEST_CODE)
B. startActivity(Intent(MediaStore.ACTION_IMAGE_CAPTURE))
C. startActivityForResult(MediaStore.ACTION_IMAGE_CAPTURE, REQUEST_CODE)
D. startActivityForResult(Intent(REQUEST_CODE), MediaStore.ACTION_IMAGE_CAPTURE)
Solution
Step 1: Check the method signature
startActivityForResult requires an Intent and a request code integer.
Step 2: Verify the Intent creation
The Intent must be created with MediaStore.ACTION_IMAGE_CAPTURE as the action.
Final Answer:
startActivityForResult(Intent(MediaStore.ACTION_IMAGE_CAPTURE), REQUEST_CODE) -> Option A
Hint: Always pass request code with Intent in startActivityForResult [OK]
Common Mistakes:
Omitting request code parameter
Using wrong Intent constructor
Misunderstanding startActivityForResult signature
5. You want to save a full-size photo taken by the camera to a file in your app. Which approach correctly combines camera intent and file handling in Kotlin?
hard
A. Save photo by reading camera app cache directory after intent finishes
B. Start camera intent without extras, then save thumbnail from data extras
C. Create a file URI, pass it with Intent extra MediaStore.EXTRA_OUTPUT, then start camera intent
D. Use MediaStore.ACTION_VIDEO_CAPTURE intent to save photo file
Solution
Step 1: Understand full-size photo saving
To save a full-size photo, you must provide a file URI where the camera app saves the image.
Step 2: Use Intent extra MediaStore.EXTRA_OUTPUT
Pass the file URI as an extra in the camera intent using MediaStore.EXTRA_OUTPUT before starting the intent.
Step 3: Start camera intent with this setup
This ensures the camera saves the full photo to your file, not just a thumbnail in data extras.
Final Answer:
Create a file URI, pass it with Intent extra MediaStore.EXTRA_OUTPUT, then start camera intent -> Option C
Quick Check:
File URI + EXTRA_OUTPUT = full photo saved [OK]
Hint: Use EXTRA_OUTPUT with file URI for full-size photos [OK]
Common Mistakes:
Relying on thumbnail from data extras only
Not providing file URI to camera intent
Using video capture intent for photos
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.