googlesamples / easypermissions

Simplify Android M system permissions
https://firebaseopensource.com/projects/googlesamples/easypermissions/
Apache License 2.0
9.87k stars 1.46k forks source link

Add a judgment condition(>API 26) when calling "FragmentManager.isSta… #262

Closed CaiPeng closed 5 years ago

CaiPeng commented 6 years ago

Add a judgment condition(>API 26) when calling "FragmentManager.isStateSaved" method.

googlebot commented 6 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers
CaiPeng commented 6 years ago

I signed it!

googlebot commented 6 years ago

CLAs look good, thanks!

samtstern commented 6 years ago

@CaiPeng can you explain a bit why this addition is needed?

CaiPeng commented 6 years ago

When the dialog is shown, I clicked the denied button, and then my App crashed. The log shows: java.lang.NoSuchMethodError: No virtual method isStateSaved()Z in class Landroid/support/v4/app/FragmentManager; or its super classes (declaration of 'android.support.v4.app.FragmentManager' appears in /data/app/.../split_lib_dependencies_apk.apk:classes2.dex) at pub.devrel.easypermissions.RationaleDialogFragmentCompat.showAllowingStateLoss(RationaleDialogFragmentCompat.java:48) at pub.devrel.easypermissions.helper.BaseSupportPermissionsHelper.showRequestPermissionRationale(BaseSupportPermissionsHelper.java:43)

samtstern commented 6 years ago

The FragmentManager in the class you're modifying here comes from the support library. The isStateSaved method was added in support lib 26.0.1: https://developer.android.com/reference/android/support/v4/app/FragmentManager#isstatesaved

What are your app dependencies? Are you using a lower support library level? I don't think adding an SDK version check should matter here.

samtstern commented 5 years ago

@CaiPeng I am going to close this since it been a few weeks without a response and I can't see the motivation for this PR, however if you have more information please let me know and I will re-open.

Thanks for the contribution!