Coder Social home page Coder Social logo

nammu's Introduction

Nammu - Runtime Permission Helper

Nammu is a simple library to speed up working with new Runtime Permissions introduced in Android M. It allows you to easily ask for a permission, as well as to monitor if all permission that you haved ask are still there, if not it will callback with name of permission that was revoke by user.

###What are Runtime Permissions? Google docs is here. TLDR: like old-loved permissions that were ask during intallation but this time they are more dynamic (should be ask only when they are needed) and can be revoked by user at any time.

Source of all evil

###Why should I care? Beacause your user can revoke most essential part of your app and quite probably there will be a lot of app crashes. Current solution you can see here - Google sample basically there is a lot that happens with Activity that is used to check and grant permissions. Also permissions rights are checked many times in the code.

###Easy asking for permissions It removes a bit of boiler plate to keep request id, and thus simplify your code inside Activity class. call Nammu.askForPermission(Activity, PermissionString , PermissionCallback) which offers a nice callback with either succes or fail method. To use this only thing you need to add is in your Activity that you are using.

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

###Monitor permissions To keep track of access to particular permissions, all you need is init Nammu Nammu.init(Context); (can be in Application class onCreate or Activity) and add permissions to monitor such Nammu.savePermission(PermissionString); so for example Nammu.savePermission(Manifest.permission.CAMERA);. After that each time you want to make sure if permissions are still there - Nammu.permissionCompare(Activity, PermissionListener); and PermissionListener will be called if some Permission was removed.

###Extras As library monitors your Permissions at any point of time (just call init()) you can get list of monitored Persmissions -Nammu.getPrevPermissions(), removed some Nammu.removePermission(PermissionString), or check if is monitored Nammu.containsPermission(PermissionString).

###How to import it? As for now it is NOT hosted at Maven/JCenter etc. as it is based on preview build of Android M which SDK is not available on those platforms. Till that time just copy/paste all classes from library module or even whole module.

nammu's People

Contributors

tajchert avatar

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.