GithubHelp home page GithubHelp logo

googlesamples / easypermissions Goto Github PK

View Code? Open in Web Editor NEW
9.8K 278.0 1.5K 635 KB

Simplify Android M system permissions

Home Page: https://firebaseopensource.com/projects/googlesamples/easypermissions/

License: Apache License 2.0

Java 100.00%
android android-library permissions

easypermissions's Introduction

EasyPermissions Build Status Android Weekly

EasyPermissions is a wrapper library to simplify basic system permissions logic when targeting Android M or higher.

Note: If your app is written in Kotlin consider the easypermissions-ktx library which adds Kotlin extensions to the core EasyPermissions library.

Installation

EasyPermissions is installed by adding the following dependency to your build.gradle file:

dependencies {
    // For developers using AndroidX in their applications
    implementation 'pub.devrel:easypermissions:3.0.0'
 
    // For developers using the Android Support Library
    implementation 'pub.devrel:easypermissions:2.0.1'
}

Usage

Basic

To begin using EasyPermissions, have your Activity (or Fragment) override the onRequestPermissionsResult method:

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);

        // Forward results to EasyPermissions
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
    }
}

Request Permissions

The example below shows how to request permissions for a method that requires both CAMERA and ACCESS_FINE_LOCATION permissions. There are a few things to note:

  • Using EasyPermissions#hasPermissions(...) to check if the app already has the required permissions. This method can take any number of permissions as its final argument.
  • Requesting permissions with EasyPermissions#requestPermissions. This method will request the system permissions and show the rationale string provided if necessary. The request code provided should be unique to this request, and the method can take any number of permissions as its final argument.
  • Use of the AfterPermissionGranted annotation. This is optional, but provided for convenience. If all of the permissions in a given request are granted, all methods annotated with the proper request code will be executed(be sure to have an unique request code). The annotated method needs to be void and without input parameters (instead, you can use onSaveInstanceState in order to keep the state of your suppressed parameters). This is to simplify the common flow of needing to run the requesting method after all of its permissions have been granted. This can also be achieved by adding logic on the onPermissionsGranted callback.
@AfterPermissionGranted(RC_CAMERA_AND_LOCATION)
private void methodRequiresTwoPermission() {
    String[] perms = {Manifest.permission.CAMERA, Manifest.permission.ACCESS_FINE_LOCATION};
    if (EasyPermissions.hasPermissions(this, perms)) {
        // Already have permission, do the thing
        // ...
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, getString(R.string.camera_and_location_rationale),
                RC_CAMERA_AND_LOCATION, perms);
    }
}

Or for finer control over the rationale dialog, use a PermissionRequest:

EasyPermissions.requestPermissions(
        new PermissionRequest.Builder(this, RC_CAMERA_AND_LOCATION, perms)
                .setRationale(R.string.camera_and_location_rationale)
                .setPositiveButtonText(R.string.rationale_ask_ok)
                .setNegativeButtonText(R.string.rationale_ask_cancel)
                .setTheme(R.style.my_fancy_style)
                .build());

Optionally, for a finer control, you can have your Activity / Fragment implement the PermissionCallbacks interface.

public class MainActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);

        // Forward results to EasyPermissions
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
    }

    @Override
    public void onPermissionsGranted(int requestCode, List<String> list) {
        // Some permissions have been granted
        // ...
    }

    @Override
    public void onPermissionsDenied(int requestCode, List<String> list) {
        // Some permissions have been denied
        // ...
    }
}

Required Permissions

In some cases your app will not function properly without certain permissions. If the user denies these permissions with the "Never Ask Again" option, you will be unable to request these permissions from the user and they must be changed in app settings. You can use the method EasyPermissions.somePermissionPermanentlyDenied(...) to display a dialog to the user in this situation and direct them to the system setting screen for your app:

Note: Due to a limitation in the information provided by the Android framework permissions API, the somePermissionPermanentlyDenied method only works after the permission has been denied and your app has received the onPermissionsDenied callback. Otherwise the library cannot distinguish permanent denial from the "not yet denied" case.

@Override
public void onPermissionsDenied(int requestCode, List<String> perms) {
    Log.d(TAG, "onPermissionsDenied:" + requestCode + ":" + perms.size());

    // (Optional) Check whether the user denied any permissions and checked "NEVER ASK AGAIN."
    // This will display a dialog directing them to enable the permission in app settings.
    if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
        new AppSettingsDialog.Builder(this).build().show();
    }
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == AppSettingsDialog.DEFAULT_SETTINGS_REQ_CODE) {
        // Do something after user returned from app settings screen, like showing a Toast.
        Toast.makeText(this, R.string.returned_from_app_settings_to_activity, Toast.LENGTH_SHORT)
                .show();
    }
}

Interacting with the rationale dialog

Implement the EasyPermissions.RationaleCallbacks if you want to interact with the rationale dialog.

@Override
public void onRationaleAccepted(int requestCode) {
    // Rationale accepted to request some permissions
    // ...
}

@Override
public void onRationaleDenied(int requestCode) {
    // Rationale denied to request some permissions
    // ...
}

Rationale callbacks don't necessarily imply permission changes. To check for those, see the EasyPermissions.PermissionCallbacks.

LICENSE

	Copyright 2017 Google

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

easypermissions's People

Contributors

alirezaafkar avatar berviantoleo avatar danke77 avatar dcgavril avatar eavsievich avatar elsennov avatar fly2013 avatar friederbluemle avatar henriquenfaria avatar jaibatrik avatar jmarkovic avatar leedenison avatar lucmousinho avatar markmals avatar mikebayles avatar pengfeigao avatar prempalsingh avatar samtstern avatar sebkur avatar seventhmoon avatar supercilex avatar xns1001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easypermissions's Issues

Single callback instead of 2?

In a future version, could we have a single callback for the results, instead of onPermissionsGranted and onPermissionsDenied, perhaps something like

void onPermissionsResults(int resquestCode, List<String> permsGranted, List<String> permsDenied)

This would be much more useful. As it stands, I cannot have one callback that will tell me that I can use to figure both whether all were granted, and if not, which ones were not granted, so I can know whether to continue my application, or notify the user and stop. With two callbacks, its much more difficult.

I just don't know where to feedback the issue

why the nexus 6 and nexus6p didn't recevice nougat update anymore . THe release date is 8 -22..Two weeks later ,the old device have not recevice it ...I even want to change my phone to iphone 7 . why ?
THere can't be any tech issuse...The only reason should be you want sell the new nexus ...

Prevent rationale and permission denied dialog from showing multiple times

My use case is that I have this "Shake to get the current location" which I show the request permission rationale dialog when the user shakes.
The tricky part is some users shake more than they should and the dialog appears more than one time.

I am sure this might not be case for most people and the simplest fix would be just

if(!dialog.isShowing()) {
    dialog.show();
}

in both requestPermissions and checkDeniedPermissionsNeverAskAgain.
If this is trivial, I would just include the source codes in the app and make the change myself.
Otherwise, I could send a PR.

Thanks for the awesome lib!

Exceptions?

it's a weird issue
when i use plugin compile 'pub.devrel:easypermissions:0.1.9'

Everything works perfects
As soon as I moved to latest build compile 'pub.devrel:easypermissions:0.2.1'

I got binary XML exception on floating button, coordinate layouts?

request permission method void ?? change it to boolean

 if(EasyPermissions.requestPermissions(this, "This App requires certain dangerous permission that you need to activate. Allow...?", PERM, perms)){
                    //return true here means user has accept to allow viewing the permission prompt
                } else {
                    //return false here exit the app.
                }

is it possible to change void and make it boolean.

i want to check the statement above if ever the user clicks cancel he is allowed in the app which i don't want only if return true then allow
in the return false i want to exit the app if he deny the message permission

Image
actually at the moment its not the case because its VOID can you make the change..Thanks in adv...

Can't be used in Activity?

If i used it in activity.first i refused,then i open it, show a dialog i click confirm it crashed.if i use AppCompatActivity don't have this problem.
java.lang.ClassCastException: com.example.me.androdnewfeature.MainActivity cannot be cast to android.support.v4.app.FragmentActivity at pub.devrel.easypermissions.RationaleDialogClickListener.onClick(RationaleDialogClickListener.java:57) at android.support.v7.app.AlertController$ButtonHandler.handleMessage(AlertController.java:161) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Issue if requested permission denied by user.

It seems like there is an issue with this as it is calling request permission if user has denied the permission request. App perform slow, i am facing issue with text input if app user has denied the permission, logcat suggests App is requesting permission on continues basis.

App crashes

Once I denied permission permanently(Never ask) and after that when I try to call the same requestPermission method, app crashes.

Mention that the library is on Jcenter

It might be useful to note that you must have jcenter() in the build.gradle repositories. I kept getting Error:Failed to resolve: pub.devrel:easypermissions:0.3.0 and was a bit dumbfounded until I realized I only had mavenCentral()

Update: I now see here that Jcenter has been the default for a while...I guess the code I was working on was older than I thought! Feel free to close this issue.

Unrelated: The Android Quickstart says to use 0.2.1

Could not create plugin of type 'AndroidMavenPlugin'

Hello,
upon building your app in Android Studio 2.2 Beta 2 with gradle plugin com.android.tools.build:gradle:2.2.0-beta2, I get the following error:

Error:FAILURE: Build failed with an exception.

  • Where:
    Script '/Users/igorganapolsky/workspace/git/google/easypermissions/easypermissions/maven.gradle' line: 1
  • What went wrong:
    A problem occurred evaluating script.
    Failed to apply plugin [id 'com.github.dcendents.android-maven']
    Could not create plugin of type 'AndroidMavenPlugin'.

If I debug the build from commandline, I see the following info:

Caused by: org.gradle.internal.service.UnknownServiceException: No service of type Factory available in ProjectScopeServices.

Any ideas?

Thanks,
Igor

Support for Overlay or DrawOverOtherApps Permission

Generally, this permission is allowed for most of the devices and APIs. It is a part of SYSTEM_ALERT_WINDOW permission. Following devices and APIs specially need to request it to draw over other apps. For e.g. drawing Chat Heads like Facebook Messenger.

Android KitKat 4.4 - 4.4.2
Android Marshmallow 6.0.0+ (not sure about 6.0.0+)
Xiaomi's Redmi
Meizu phones

I check for this permission like this:

if (!Settings.canDrawOverlays()) {
      // request the permission
} else { 
      // continue, permission is allowed
      doSomething();
}

I, also, check that back in onResume()

Can you support this?

Private methods with @AfterPermissionGranted annotation is not executed

I was looking at Request Permission example in Readme.md. I don't know if this is a bug or not, but private methods with @AfterPermissionGranted annotation will not be executed. I debug and found out in EasyPermissions.java line 176, getMethods() returns public methods according to JavaDoc

I change my method to public and it works.

the HTC D10w phone is invalid

I have a HTC D10w phone, but it doesn't work.
`
public void callPhone()
{
Intent intent = new Intent(Intent.ACTION_CALL);
Uri data = Uri.parse("tel:" + "10086");
intent.setData(data);

// first time -> false,
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) !=
PackageManager.PERMISSION_GRANTED)
{
// no dialog
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CALL_PHONE},
MY_PERMISSIONS_REQUEST_CALL_PHONE);
return;
}
//has dialog
startActivity(intent);
}

@OverRide
public void onRequestPermissionsResult(int requestCode, String[] permissions,
int[] grantResults)
{
// granted,no dialog
if (requestCode == MY_PERMISSIONS_REQUEST_CALL_PHONE)
{
if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
{
callPhone();
} else
{
// Permission Denied
Toast.makeText(this, "Permission Denied", Toast.LENGTH_SHORT).show();
}
return;
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
`

try it?

can not get the correct result

in HuaWei Mate7 (android 4.4) when i ask for camera permission, i choose refuse ,but show me i have the permission and can not call camera.
what should i do ?

Annoteated methods not run when method is in super class

for (Method method : clazz.getDeclaredMethods()) { if (method.isAnnotationPresent(AfterPermissionGranted.class)) { /* more code */ } }

When using a base class (e.g. BaseFragment) which has annoteated AfterPermissionGranted methods then these are not run. The reason seems to be that clazz.getDeclaredMethods() only returns the methods which are declared in the class itself and not the superclass ones.

This might be intented behaviour, but just wanted to check.

No callback when using in android.app.Fragment

When using the library on an android.app.Fragment, I'm not receiving any callback if the rationale has been shown before the permission request. It works well if the rationale is not displayed.

I've taken a look at the code and it looks like the problem comes from the click listener for the rationale dialog, created here in RationaleDialogClickListener.java :

@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
    RationaleDialogClickListener(RationaleDialogFragment dialogFragment,
                                 RationaleDialogConfig config,
                                 EasyPermissions.PermissionCallbacks callbacks) {

        mHost = dialogFragment.getActivity();
        mConfig = config;
        mCallbacks = callbacks;
    }

We are setting the host as the activity, not the fragment itself.
But then this host is used to perform another permission request, but not using a fragment host will makes it so the activity will not propagate the result to fragments.

What do you think ? Am I missing something ?

rationale string not display in the very first time permission request

EasyPermissions.requestPermissions(this, "I need this", 100 , perms);

The sentence "I need this" not displayed the very first time in requesting permission, but for further more request it will display.
If I turn permission on and off it again from setting. the sentence not display again for first request!

I am using easypermissions:0.1.8 on LG G4 H815P android 6.0

Not working on Service

Hi, how can i requestPermissions inside the Service? Since the code will throw an exception if it is accessed from outside of activity or fragment.
Thanks :)

request call permission, can't click to allow

easypermission version -> 0.2.1 phone model -> nexus5 6.0 has bean root

    @AfterPermissionGranted(REQUEST_PHONE_PER)
    private void methodRequestPhonePer() {
        String[] perms = {Manifest.permission.READ_PHONE_STATE};
        if (EasyPermissions.hasPermissions(this, perms)) {
            // login
            login();
            return;
        }
        EasyPermissions.requestPermissions(this, getString(R.string.per_phone), REQUEST_PHONE_PER, perms);
    }

    private void login() {
        new LoginPresenter(TaskProvider.provideTasksRepository(this), this);
        mPresenter.start();
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
    }

    @Override
    public void onPermissionsGranted(int i, List<String> list) {
        login();
    }

    @Override
    public void onPermissionsDenied(int i, List<String> list) {
        PermissUtils.somePermissionPermanentlyDenied(this, list);
    }

SecurityException

I get the following error via crashlyics on a 5.1.1 Samsung SM-A710Y device. It's a one out of 10k. Anyone has an idea how that can happen?

Fatal Exception: java.lang.SecurityException
Client must have ACCESS_FINE_LOCATION permission to request PRIORITY_HIGH_ACCURACY locations.

String[] perms = {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION};
if (EasyPermissions.hasPermissions(this, perms)) {
     LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, this);
}

Request dialog not being thrown

When requesting permissions using EasyPermissions request method, the permission goes automatically to denied without showing any kind of dialog.
captura de pantalla 2016-12-21 a las 16 33 33

Methods not executing

Any method with @AfterPermissionGranted annotation is not executed and the overriden methods onRequestPermissionsResult, onPermissionsGranted, and onPermissionsDenied do not execute for me. I implemented the class inside of a fragment class. I have tried to make the method with the annotation publc and private, both failed.

The permission does get granted/denied so it seems to be partially working for me. I would like to get the code executed soon as the permissions are granted working though.

Having issues getting the newest version.

Failed to resolve: pub.devrel:easypermissions:0.1.9
But 0.1.8 still works No Problem.

"---Edit---" It works if I use:

compile 'pub.devrel:easypermissions:0.1.9@aar'

Why multiple request asked at the same time?

At starting of the app, I have READ_SMS permission and WRITE_EXTERNAL_STORAGE permission after signup.
Now the issue is as soon as I allow READ_SMS permission, it asks me for WRITE_EXTERNAL_STORAGE permission after that only(signup not done). How to stop this behavior and ask user permission only when required.

if user grante all permissions very quickly ,then the app will crash

if one use this repository normal,then everything is fine;
but i try to test it :)
step 1:
uninstall the app ,and then install app,then grant all permissions very quickly ,then the app will crash;
i don't see the crash log :( ..
but i reopen the app,and crash again ,and see the log:

02-09 14:14:54.695 3013-3013/com.hgrica.obdclient E/AndroidRuntime: FATAL EXCEPTION: main Process: com.hgrica.obdclient, PID: 3013 java.lang.ClassCastException: com.hgrica.obdclient.view.WelcomeActivity cannot be cast to android.support.v4.app.FragmentActivity at pub.devrel.easypermissions.RationaleDialogClickListener.onClick(RationaleDialogClickListener.java:57) at android.support.v7.app.AlertController$ButtonHandler.handleMessage(AlertController.java:161) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:150) at android.app.ActivityThread.main(ActivityThread.java:5546) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)


i notice this :com.hgrica.obdclient.view.WelcomeActivity cannot be cast to android.support.v4.app.FragmentActivity
that means i should use a activity that extends FragmentActivity?
but u never mention it..


step2:
uninstall the app,and reinstall the app.oh.still the app crash again.
i notice a important thing: EasyPermissions.hasPermissions(this, PERMISSIONS_ALL) in the method which has @AfterPermissionGranted(REQUEST_ALL) dosen't work well;i have already granted all permissions,but EasyPermissions.hasPermissions(this, PERMISSIONS_ALL) still return false until i restart the app or just grant the permission(although i have already granted it)again.

:(


here is the activity code :)
`public class WelcomeActivity extends BaseFragmentActivity implements EasyPermissions.PermissionCallbacks{
private static final String TAG = WelcomeActivity.class.getSimpleName();

//all permission i want
public static String[] PERMISSIONS_ALL = {Manifest.permission.READ_EXTERNAL_STORAGE,
        Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.ACCESS_FINE_LOCATION,
        Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.READ_PHONE_STATE
};
//all
public static final int REQUEST_ALL = 4;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_welcome);
    requestPermissions();
}

private void requestPermissions() {
    requestAllPermissions();
}

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
}



@Override
public void onPermissionsGranted(int requestCode, List<String> perms) {
    LogUtil.d(TAG,"onPermissionsGranted(),requestCode:"+requestCode);
    for (String perm:perms){
        LogUtil.d(TAG,"onPermissionsGranted(),perm:"+perm);
    }
}

@Override
public void onPermissionsDenied(int requestCode, List<String> perms) {
    LogUtil.d(TAG,"onPermissionsDenied(),requestCode:"+requestCode);
    for (String perm:perms){
        LogUtil.d(TAG,"onPermissionsDenied(),perm:"+perm);
    }
}

@AfterPermissionGranted(REQUEST_ALL)
private void requestCodeQRCodePermissions() {
    if (!EasyPermissions.hasPermissions(this, PERMISSIONS_ALL)) {
        LogUtil.d(TAG,"what~~~~~~~~~~~no");
        EasyPermissions.requestPermissions(this, "come on", REQUEST_ALL, PERMISSIONS_ALL);
    }else {
        // Already have permission, do the thing
        LogUtil.d(TAG,"what~~~~~~~~~~~yes");
    }
}

}`


so i try to do sth for these problem:

step1: i try to make activity extends FragmentActivity..
it work! well..er..fine.

setp2: still finding way.....
so i need your help!!thx

RuntimeException has wrong message

The RuntimeException thrown in runAnnotatedMethods method in the following if block has wrong message -

if (method.getParameterTypes().length > 0) { throw new RuntimeException( "Cannot execute non-void method " + method.getName()); }

The message should say something like "Cannot execute method [method name] because it is non-void method and/or has input parameters"

Rationale dialog is not showing buttons

Rationale button which showing the message on the first rejection of the permission is not showing any of the buttons like 'ok' or 'cancel'.

User will not get to know what to do in that case.

I checked it on Samsung s6 and Moto G4 plus

Short-circuit the library much earlier on API < 23

This library should just do nothing on pre-M devices, but our API-level checks are too far down the pipeline which creates a lot of code branches that are practically unreachable but just there to satisfy the lint checker and the compiler.

See #61 for some discussion.

Crash when requesting permissions

Using version 0.2.1 I am sometimes seeing this crash in production:

Exception java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=101, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS VirtualScreenParam=Params{mDisplayId=-1, null, mFlags=0x00000000)} (has extras) }} to activity {com.google.android.apps.santatracker/com.google.android.apps.santatracker.presentquest.MapsActivity}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
android.app.ActivityThread.deliverResults (ActivityThread.java:4925)
android.app.ActivityThread.handleSendResult (ActivityThread.java:4968)
android.app.ActivityThread.access$1600 (ActivityThread.java:222)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1849)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:158)
android.app.ActivityThread.main (ActivityThread.java:7229)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
Caused by java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
android.support.v4.app.FragmentManagerImpl.checkStateLoss (FragmentManager.java:1533)
android.support.v4.app.FragmentManagerImpl.enqueueAction (FragmentManager.java:1551)
android.support.v4.app.BackStackRecord.commitInternal (BackStackRecord.java:696)
android.support.v4.app.BackStackRecord.commit (BackStackRecord.java:662)
android.support.v4.app.DialogFragment.show (DialogFragment.java:139)
pub.devrel.easypermissions.EasyPermissions.showRationaleDialogFragmentCompat (EasyPermissions.java:176)
pub.devrel.easypermissions.EasyPermissions.requestPermissions (EasyPermissions.java:149)
pub.devrel.easypermissions.EasyPermissions.requestPermissions (EasyPermissions.java:104)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.