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
• 11,450 points
168 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
• 12,890 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
• 11,450 points
225 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
• 11,450 points
80 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
• 2,960 points
139 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,350 points
3,069 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
1,730 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
516 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,630 points
466 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
• 12,890 points
86 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