All Projects → armcha → SimplePermissions

armcha / SimplePermissions

Licence: other
This library allows you easily implement Android marshmallow permissions. The list of permissions, if I miss any permission please add and send me pull request.

Programming Languages

java
68154 projects - #9 most used programming language

SimplePermissions

![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal- Simple--Permissions-green.svg?style=true) ####This library allows you easily implement Android marshmallow permissions.

The list of permissions, if I miss any permission please add and send me pull request.

Download sample apk

Download

repositories {
    maven {
        url 'https://dl.bintray.com/armcha/maven'
    }
}
compile 'com.github.armcha:SimplePermissions:1.0.0'

How to use

###Step 1. Extend your activity/fragment from PermissionActivity/PermissionFragment

public class MyActivity extends PermissionActivity

or

public class MyFragment extends PermissionFragment

###Step 2.

Request single permission

requestPermission(Permission.CAMERA, new SinglePermissionCallback() {
                @Override
                public void onPermissionResult(boolean permissionGranted, boolean isPermissionDeniedForever) {
                    if (permissionGranted) {
                        //Do your work
                    } else if (isPermissionDeniedForever) {
                        PermissionUtils.openApplicationSettings(context);
                    } else {
                        Toast.makeText(context, "Please grant permissions", Toast.LENGTH_SHORT).show();
                    }
                }
            });

Request multiple permissions

Permission[] permissions = {Permission.CALL_PHONE, Permission.SEND_SMS, Permission.FINE_LOCATION};
requestPermissions(permissions, new MultiplePermissionCallback() {
            @Override
            public void onPermissionGranted(boolean allPermissionsGranted, List<Permission> grantedPermissions) {
                
            }

            @Override
            public void onPermissionDenied(List<Permission> deniedPermissions, List<Permission> foreverDeniedPermissions) {

            }
        });

Permission utils

PermissionUtils.openApplicationSettings(context);
PermissionUtils.isMarshmallowOrHigher()

Contact

Pull requests are more than welcome. Please fell free to contact me if there is any problem when using the library.

License

  SimplePermissions library for Android
  Copyright (c) 2017 Arman Chatikyan (https://github.com/armcha/SimplePermissions).
  
  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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].