Android library for permissions request (updated 27.11.2017)

Overview

NoPermission

Android Arsenal androidweekly.cn Download API

Simple Android library for permissions request. Consists of only one class.

Why NoPermission:

  • Not a framework. It's just one class
  • Dialog with an explanation of why the application needs permission (with custom title, message and button text and color)
  • Never ask again feature
  • Automatic check whether the permission is granted or not (don't need to check api version)
  • Fragments support

Gradle

compile 'ru.alexbykov:nopermission:1.1.2'

Install

PermissionHelper permissionHelper = new PermissionHelper(this); //don't use getActivity in fragment!

        permissionHelper.check(Manifest.permission.ACCESS_COARSE_LOCATION)
                .onSuccess(this::onSuccess)
                .onDenied(this::onDenied)
                .onNeverAskAgain(this::onNeverAskAgain)
                .run();
Multiply permissions and other settings:
   permissionHelper.check(Manifest.permission.READ_CONTACTS, Manifest.permission.Manifest.permission.READ_CONTACTS)
                   .withDialogBeforeRun(R.string.dialog_before_run_title, R.string.dialog_before_run_message, R.string.dialog_positive_button)
                   .setDialogPositiveButtonColor(android.R.color.holo_orange_dark)
                   .onSuccess(this::onSuccess)
                   .onDenied(this::onDenied)
                   .onNeverAskAgain(this::onNeverAskAgain)
                   .run();
onRequestPermissionsResult:
 @Override
  public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
        permissionHelper.onRequestPermissionsResult(requestCode, permissions, grantResults);
   }
Open application settings activity

If user check "Never ask again", you can redirect him to application settings.

permissionHelper.startApplicationSettingsActivity();

Don't forget explain it manually (with dialog). In future this feature will be realised in library.

Changelog

Be sure to review the changes list before updating the version

TODO

  • Unit tests
  • Getting rid of the onRequestPermissionsResult method

Contributing

If you find any bug, or you have suggestions, don't be shy to create issues or make a PRs in the develop branch. You can read contribution guidelines here

License

Copyright 2017 Mike Antipiev and Alex Bykov

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.
You might also like...
Find your ideal fitness partners according to your preferences and interact with them whenever you want! All this with no hassle, because there's FitMate! Take timed challenges updated daily, read blogs related to health, and be a part of numerous communities too! During covid times, partner with your FitMate to achieve your fitness goals at home. Long-term support releases of Birday updated with the latest translations
Long-term support releases of Birday updated with the latest translations

Note: this document is still a work in progress. Birday LTS This repository is based on the 2.1.0 release of https://github.com/m-i-n-a-r/birday. You

🔓 Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.
🔓 Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.

EasyPermissions-ktx Kotlin version of the popular googlesample/easypermissions wrapper library to simplify basic system permissions logic on Android M

Android Library to help you with your runtime Permissions.
Android Library to help you with your runtime Permissions.

PermissionHelper Android Library to help you with your runtime Permissions. Demo Android M Watch it in action. Pre M Watch it in action. Nexus 6 (M) N

Android Library for requesting Permissions with Kotlin Coroutines or AndroidX LiveData

PEKO PErmissions with KOtlin Android Permissions with Kotlin Coroutines or LiveData No more callbacks, builders, listeners or verbose code for request

🔓 Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.
🔓 Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.

🔓 Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.

A declarative API to handle Android runtime permissions.

PermissionsDispatcher Fully Kotlin/Java support Special permissions support 100% reflection-free PermissionsDispatcher provides a simple annotation-ba

Android runtime permissions powered by RxJava2

RxPermissions This library allows the usage of RxJava with the new Android M permission model. Setup To use this library your minSdkVersion must be =

Simplifying Android Permissions
Simplifying Android Permissions

Gota Libary With Android 6.0 Marshmallow, Google introduced a new permission model that allows users to better understand why an application may be re

Simplify Android M system permissions

EasyPermissions EasyPermissions is a wrapper library to simplify basic system permissions logic when targeting Android M or higher. Note: If your app

Simplifying Android Permissions
Simplifying Android Permissions

Gota Libary With Android 6.0 Marshmallow, Google introduced a new permission model that allows users to better understand why an application may be re

Get a unique ID for Android devices without any permissions.

Java and Kotlin Android library. Uniquely identify an Android device without any permissions and API restrictions. The recommended approach using DRM API.

Android permissions as suspend functions
Android permissions as suspend functions

Warden Permission handling in Android can be complicated. It requires boilerplate code to setup the permission request, receive the result and then fo

A Android app Permissions with Kotlin Flow APIs

Know about real-time state of a Android app Permissions with Kotlin Flow APIs. Made with ❤️ for Android Developers.

Sentinel is a simple one screen UI which provides a standardised entry point for tools used in development and QA alongside device, application and permissions data.
Sentinel is a simple one screen UI which provides a standardised entry point for tools used in development and QA alongside device, application and permissions data.

Sentinel Sentinel is a simple one screen UI that provides standardised entry point for tools used in development and QA alongside device, application

Easy way to handle all permissions

BestPermissionUtil You can read the story from here https://hamurcuabi.medium.com/permissions-with-the-easiest-way-9c466ab1b2c1 Prerequisites Add this

PermissionX is an extension Android library that makes Android runtime permission request extremely easy
PermissionX is an extension Android library that makes Android runtime permission request extremely easy

PermissionX is an extension Android library that makes Android runtime permission request extremely easy. You can use it for basic pe

Android Easy Http - Simplest android http request library.
Android Easy Http - Simplest android http request library.

Android Easy Http Library 繁體中文文檔 About Android Easy Http Library Made on OkHttp. Easy to do http request, just make request and listen for the respons

Comments
  • must run onSuccess on pre Build.VERSION_CODES.M

    must run onSuccess on pre Build.VERSION_CODES.M

    i think you must call successListener.onSuccess(); on pre Build.VERSION_CODES.M

    https://github.com/NoNews/NoPermission/blob/master/library/src/main/java/ru/alexbykov/nopermission/PermissionHelper.java#L58

    public void run() {
            if (isNeedAskPermission()) {
    
                if (successListener != null && failureListener != null && newerAskAgainListener != null) {
                    activity.requestPermissions(permissions, PERMISSION_REQUEST_CODE);
                } else
                    throw new RuntimeException("OnPermissionSuccessListener or OnPermissionFailureListener not implemented. Use methods: onSuccess and onFailure");
            } else if(successListener != null) {
                    successListener.onSuccess();
            }
        }
    
    enhancement 
    opened by DJafari 4
  • Can request only one set of permissions at a time

    Can request only one set of permissions at a time

    Hi, sorry I have not replied sooner but this month has been a hell.

    I found out another annoying issue. The code in android is here:

    https://android.googlesource.com/platform/frameworks/base.git/+/master/core/java/android/app/Activity.java#4393

    The fact is that, by adding permissionHelper.check(permission) calls on demand may not work if an app requests 2 permissions in the same activity onCreate (I suppose). This is a case for reeturning an empty array new String[0].

    I suppose, the fix in this case is refactor the code :-(

    opened by pellyadolfo 1
  • Multiple request issue

    Multiple request issue

    When multiple permissions are requested at the same time, the 'onSuccess' listener is called ONCE only if ALL permissions are granted. I was expecting to have a call to 'onSuccess' for each granted permission, and 'onDenied' for each denied.

    bug is in "onRequestPermissionsResult"

    opened by cdebast 1
  • Bug when close and reopen

    Bug when close and reopen

    Thanks for this class. The beauty of simplicity.

    There seems to be a bug when showing the permission request to the user on the splash screen. If the user cleans his dialog and opens again the app, this secod time, the permissionHelper.check() method automatically executes 'success' and assumes to be granted, without showing the dialog again and without actually having the permission granted.

    In this way, clearing the screen and reopening the app in the same point (i.e. moving the app to background and back to foreground) we can navigate the app skipping the dialogs until the final security crash.

    bug 
    opened by pellyadolfo 8
Releases(v.1.1.2)
  • v.1.1.2(Nov 19, 2017)

    • new method withDialogBeforeRun to explain why the application needs permission
    • new method setDialogPositiveButtonColor(android.R.color.holo_orange_dark)
    • method unsubscribe is deprecated. Not it no necessary, now it works automatically
    • refactoring, javadoc and sample application updated
    Source code(tar.gz)
    Source code(zip)
  • v.1.1.1(Nov 5, 2017)

    • support permission requests for fragments (sample with fragment)
    • new method startApplicationSetting (for manually permission manage, for example if user check "Never ask again")
    • method onFailure is deprecated. Use method onDenied
    • refactoring, javadoc and sample application updated.
    Source code(tar.gz)
    Source code(zip)
  • v.1.1.0(Oct 11, 2017)

  • v.1.0.8(Sep 18, 2017)

    • method onSuccess is called immediately if the API version < 23 (Android 6.0) (@DJafari, #1, #2 )
    • fixed bug with re-requesting permissions that have already been approved
    • сustom listeners replaced by Runnable (@DJafari, #2 )
    • sample application added
    Source code(tar.gz)
    Source code(zip)
Owner
Alexey Bykov
Android Software Engineer at Revolut. You can contact me at [email protected]
Alexey Bykov
Android runtime permissions powered by RxJava2

RxPermissions This library allows the usage of RxJava with the new Android M permission model. Setup To use this library your minSdkVersion must be >=

Thomas Bruyelle 10.4k Jan 8, 2023
Simplifying Android Permissions

Gota Libary With Android 6.0 Marshmallow, Google introduced a new permission model that allows users to better understand why an application may be re

Abdullah Alhazmy 72 Nov 29, 2022
Simplify Android M system permissions

EasyPermissions EasyPermissions is a wrapper library to simplify basic system permissions logic when targeting Android M or higher. Note: If your app

Google Samples 9.6k Dec 30, 2022
2017 Android Associate Developer Exam

Bug-Master-Android-Application This was the application I built to pass the Google Android Associate Exam in 2017. The app involved syncing with an in

null 0 Nov 20, 2021
API-Request - Android app that makes API Request

API-Request Android project using Retrofit and Ktor for Http Requests, built wit

Thales 2 Mar 26, 2022
Android pagination library (updated 01.05.2018)

NoPaginate Android pagination library, based on @MarkoMilos repository Paginate Loading Item Error Item Gradle implementation 'ru.alexbykov:nopaginate

Alexey Bykov 183 Nov 22, 2022
DuGuang 1k Dec 14, 2022
A reliable android app that shows upcoming fixtures, updated league tables, and top goal scorers in a league

SwiftScore A football stats and livescore app built with Kotlin,MVVM architecture,Retrofit, Coroutines and Navigation Components Demo Screenshots API

Breens Mbaka 12 Jul 7, 2022
A reliable android app that shows upcoming fixtures, updated league tables, and top goal scorers in a Premier League and French Ligue 1

RapidScore Screenshots Table of Contents Description Dependencies API Reference Lessons Learnt Contributing Roadmap Google Playstore License Author In

Breens Mbaka 12 Jul 7, 2022