Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requesting permission results into java.lang.ArrayIndexOutOfBoundsException #15928

Closed
msidlo opened this issue Sep 13, 2017 · 2 comments
Closed
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@msidlo
Copy link

msidlo commented Sep 13, 2017

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

  1. react-native -v: 0.45.1
  2. node -v: 7.9.0
  3. npm -v: 4.2.0
  4. yarn --version: 0.23.2

Then, specify:

  • Target Platform: Android
  • Development Operating System: macOC Sierra
  • Build tools: Android Studio

Steps to Reproduce

  1. ask for permission just like in documentation
  2. press home button
  3. open the App again and it crashes on this line
    if (results[0] == PackageManager.PERMISSION_GRANTED) {

Expected Behavior

Check results array before accessing it.
instead of
if (results[0] == PackageManager.PERMISSION_GRANTED) {
something like
if (results.length > 0 && results[0] == PackageManager.PERMISSION_GRANTED) {

Actual Behavior

On some devices app crashes after Requesting a permission on Android. App crashed on Xiaomi Redmi 4 Prime(Android 6.0.1), Lenovo C2 (Android 6.0), Sony Xperia Z3Compact (Android 6.0.1), Samsung Galaxy A3 (Android 7.0.). App is not crashing on Huawei P10 lite(Android 7) or Sony Xperia L1(Android 7). After crash, the app is restarted.

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

@RafaelMagalhaesN
Copy link
Contributor

PR #16507 @msidlo tnks for the solution ;)

facebook-github-bot pushed a commit that referenced this issue Oct 24, 2017
Summary:
Reported in Issue #15928

Fixing bug when permission showing dialog and user go to home and re-open minimized app.

1. Ask for permission
2. Minimize app (Press HomeButton)
3. Open app again via shortcut

 [ANDROID] [BUGFIX] [PermissionsModule.java] - Fixed bug when asked for permission Cause: java.lang.ArrayIndexOutOfBoundsException · length=0; index=0
Closes #16507

Differential Revision: D6133708

Pulled By: shergin

fbshipit-source-id: 9c05d1d5d16fedf718ad5113df69a4df3af62013
@stale
Copy link

stale bot commented Dec 23, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 23, 2017
@stale stale bot closed this as completed Dec 30, 2017
@facebook facebook locked and limited conversation to collaborators May 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

2 participants