nabinbhandari / Android-Permissions

Library for easy handling of android run-time permissions.
410 stars 84 forks source link

Implement Intent.FLAG_ACTIVITY_NEW_TASK handling #12

Closed polesapart closed 5 years ago

polesapart commented 5 years ago

This is needed for non-activity contexts. This should close #11 if adequately documented.

nabinbhandari commented 5 years ago

Great job. But you missed a null check. I've merged, fixed and published it to a new version.

polesapart commented 5 years ago

Nice catch!

AliAzaz commented 5 years ago

Still i'm getting this error :

Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

It's non-activity class and my code is:

String[] permissions = {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION};
    Permissions.check(MainApp.getmContext(), permissions, null/*rationale*/, null/*options*/, new PermissionHandler() {
        @Override
        public void onGranted() {
            // do your task.
            Toast.makeText(MainApp.getmContext(), "Granted", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onDenied(Context context, ArrayList<String> deniedPermissions) {
            Toast.makeText(MainApp.getmContext(), "Denied", Toast.LENGTH_SHORT).show();
        }
    });

The error is coming on Permissions.check line.

Please give me the solution ASAP...

soenkegissel commented 5 years ago

I get this error too. Sorry, can only supply you with obfocusated class: com.nabinbhandari.android.permissions.b.a (Unknown source: 129)

nabinbhandari commented 4 years ago

@AliAzaz @soenkegissel To solve this problem, pass new Options().setCreateNewTask(true) instead of 'null' to the parameter 'options'.