How get permission for camera in android Specifically Marshmallow

0 votes

Hello, I'm creating an Android app in Android Studio. I need the camera's consent in that situation. The AndroidManifest.xml file contains the code 

<uses-permission android:name="android.permission.CAMERA" />

With the exception of Marshmallow, it functions correctly on all versions of Android. How can I automatically receive camera permission? If that's not possible, how can I ask the user?

Nov 7, 2022 in Android by Edureka
• 12,690 points
3,632 views

1 answer to this question.

0 votes

To begin with, confirm that the user has given the permission:

if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA)
    == PackageManager.PERMISSION_DENIED)

Then, you might employ this to ask the user to:

ActivityCompat.requestPermissions(activity, new String[] {Manifest.permission.CAMERA}, requestCode);

Additionally, it will pop up in a dialogue in Marshmallow.

answered Nov 8, 2022 by Edureka
• 13,620 points

Related Questions In Android

0 votes
0 answers
0 votes
0 answers

How to get the device's IMEI/ESN programmatically in android?

I want to use the IMEI to ...READ MORE

Nov 16, 2022 in Android by Edureka
• 12,690 points
1,247 views
0 votes
0 answers

How to get current time and date in Android?

How can I get the current time ...READ MORE

Nov 22, 2022 in Android by Edureka
• 12,690 points
484 views
0 votes
0 answers

How do I get the current GPS location programmatically in Android?

I need to get my current location ...READ MORE

Nov 23, 2022 in Android by Ashwini
• 5,430 points
663 views
0 votes
1 answer

Running docker on Android

According to the documentation, the Android kernel is ...READ MORE

answered Aug 1, 2018 in Docker by Kalgi
• 52,360 points
3,677 views
0 votes
1 answer

Task Canceled Exception while invoking AWS Lambda

I'm guessing either the TaskCanceledException instance is ...READ MORE

answered Sep 19, 2018 in AWS by Priyaj
• 58,100 points
2,411 views
0 votes
1 answer

Is there a way to run Python on Android?

YES! An example via Matt Cutts via SL4A -- "here’s ...READ MORE

answered Sep 19, 2018 in Python by Priyaj
• 58,100 points
966 views
0 votes
1 answer

How can we get the current location in Android?

First you need to define a LocationListener to handle ...READ MORE

answered Sep 25, 2018 in Java by Parth
• 4,640 points
883 views
0 votes
1 answer
0 votes
1 answer

How to set my Activity as main activity in android?

The "intent-filter" in "AndroidManifest.xml" allows you to ...READ MORE

answered Nov 8, 2022 in Android by Edureka
• 13,620 points
2,232 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP