Android is not asking for permission

Working on a React Native project and facing some challenges, I find myself in need of requesting Video and Image permissions. Despite already including the users in the androidmanifest file,

I'm importing necessary modules from 'react-native' to handle permissions in my Bin component:

const requestCameraPermission = async () => {
    try {
      const granted = await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES,
        {
          title: "Cool Photo App Camera Permission",
          message:
            "Cool Photo App needs access to your camera so you can take awesome pictures.",
          buttonNeutral: "Ask Me Later",
          buttonNegative: "Cancel",
          buttonPositive: "OK"
        }
      );
      if (granted === PermissionsAndroid.RESULTS.GRANTED) {
        console.log("You can use the camera");
      } else {
        console.log("Camera permission denied");
      }
    } catch (err) {
      console.warn(err);
    }
  };

Answer №1

Issue:

The PermissionsAndroid module does not include a constant for reading media images.

Solution #1

To workaround this issue, you can request the generic READ_EXTERNAL_STORAGE permission instead of the missing READ_MEDIA_IMAGES constant.

Solution #2

An alternative solution is to utilize a third-party library like react-native-permissions. For more information, refer to this discussion on Stack Overflow: here.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps should I take to generate an apk file from a kivy project using Github?

Can anyone provide guidance on converting a Kivy file to an APK using GitHub? I've searched online but haven't been able to find clear instructions on how to do it. Any help would be greatly appreciated as I'm struggling to convert my Kivy f ...

Modifying the appearance of a CSS element with jQuery: Step-by-step guide

The code I have is as follows: $('.signup-form-wrapper').css("style", "display: block"); $('.login-form-wrapper').css("style", "display: none"); I'm not sure why it's not working. The current appearance of ...

Facing a challenge with displaying an angularjs template within a popover

I am having trouble displaying custom HTML content in a popover when clicking on my "View" link. Although other content is rendering correctly, such as one with an ng-repeat inside it, my custom directive does not seem to be processed and displayed properl ...

Text label fails to move up when focused on in BasicTextField

When focusing on the BasicTextField, the label does not move up until I start typing. The BasicTextField I am using has the same properties as the regular TextField. I am curious why the TextField works differently from the BasicTextField that is internall ...

"Stay current with real-time updates in seconds using React technology

Check out this code snippet: const currentTime = new Date().getTime(); const targetTime = new Date('November 15, 2020').getTime(); const difference = currentTime - targetTime; let seconds = Math.floor(difference / 1000) % 60; setInterval(functio ...

Implementing dual pagination components in Vue JS for dynamic updates on click

Having two pagination components on a single page is convenient for users to navigate without scrolling too much. One component is placed at the top and the other at the bottom. The issue arises when I switch to page 2 using the top component, as the bott ...

The JQuery click function is only effective with the initial click

In this screen scraping function, the intention is to click on all the links that are stored in the variable $el. Initially, the first call to the click function is successful and it has been verified that all the links are indeed stored in $el. However, u ...

Make sure two elements are siblings in JavaScript / jQuery

Looking at the HTML structure below: <div class="wrap"> <div id="a"></div> <div id="b"></div> </div> A statement is presented as false: ($('#a').parent() == $('#b').parent()); //=> false ...

Most effective method for generating numerous branching arrays in JavaScript

When creating shorthand objects, I find that there are too many indents with other arrays and objects inside. I am building a question form that branches out to new sets of questions based on the previous one answered. Do you have any suggestions on how ...

Is it necessary to reload the page each time to see updates on the navbar in nextjs?

I recently developed a Next.js application with a Navbar component integrated into my layout.tsx file. The challenge arises when a user logs in and is redirected to the home page, which showcases a link in the Navbar for viewing their profile. However, I n ...

JavaScript event listener 'click' not functioning properly

I'm facing an issue with a click event in a script that is associated with a specific div id. When I move the mouse within the div area and click (the cursor remains unchanged), the event listener does not activate. How can I make the div area clickab ...

On the completion of jQuery Ajax when the results have been exhausted

Currently in the process of developing a simple quiz for a client that pulls data from their database using an Ajax call to load questions sequentially. While this setup is working smoothly, I am facing a challenge regarding how to efficiently determine ...

Sharing information between functions within the same controller in AngularJS

I have been working on a project which involves the use of AngularJS and MVC. I am retrieving status details data using HTTP POST, and now I need to utilize this data in another function of my controller. Despite passing the data in a scope variable named ...

"Efficiently Triggering Multiple Events with One Click in JavaScript

Hey everyone, I could use some assistance. I'm trying to execute multiple events with a single click. Currently, I can change the image in my gallery on click, but I also want to add text labels corresponding to each image. Whenever I click on a diffe ...

"Enhance input functionality by updating the value of the text input or resizing the textbox

I've been facing a challenge with updating the value of my input type=text or textbox control text value using jQuery $(window).resize(function(){});. I am aware that the event is triggered because an alert pops up when I resize the browser. Additiona ...

Encountering a Typescript error while attempting to remove an event that has a FormEvent type

Struggling to remove an event listener in Typescript due to a mismatch between the expected type EventListenerOrEventListenerObject and the actual type of FormEvent: private saveHighScore (event: React.FormEvent<HTMLInputElement>) { This is how I t ...

Experiencing complications with an Angular 2 router

When a user logs into the system, they are greeted with a navigation bar featuring options like Dashboard, Customers, and Product. Below is an excerpt from my routes file: app.routing.ts export const router: Routes = [ { path: '', redir ...

Update the image links to automatically refresh every half a second based on the values inputted in the text bars

Is there a better and simpler way to define AAAAAAAAAA, BBBBBBBBBB, and CCCCCCCCCC using the links provided in the text bars named chart1, chart2, and chart3? This learning project is being done through Notepad++ for personal use only, with no need to sa ...

Unauthorized Client Error in Workday OAuth

I am currently in the process of setting up an OAuth integration with Workday, but I am encountering an issue with an Unauthorized Client error. I have taken the necessary steps by enabling the API client, obtaining secret and access keys, and configuring ...

Storing chosen choices from various select lists with similar class name in JavaScript

I am struggling to save all the selected options in an array for future output. Despite trying various suggestions, I haven't been able to make it work yet. The class names and names cannot be modified. HTML <select class="addon addon-select" nam ...