Ask Permission - Simple RunTime permission manager

Overview

Ask Permission

https://kishanjvaghela.github.io/Ask-Permission/

Download Android Arsenal Stories in Ready

Simple RunTime permission manager

How to use

Add url to your gradle file

compile 'com.kishan.askpermission:askpermission:1.0.3'

If you got conflicting in support library then

compile('com.kishan.askpermission:askpermission:1.0.3', {
        exclude group: 'com.android.support'
    })

Now you can Ask for permission

new AskPermission.Builder(this)
        .setPermissions(Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_EXTERNAL_STORAGE)
        .setCallback(/* PermissionCallback */)
        .setErrorCallback(/* ErrorCallback */)
        .request(/* Request Code */);

Here you have two callback

PermissionCallback

@Override
  public void onPermissionsGranted(int requestCode) {
    // your code
  }

  @Override
  public void onPermissionsDenied(int requestCode) {
    // your code
  }

ErrorCallback

Example

  @Override
  public void onShowRationalDialog(PermissionInterface permissionInterface, int requestCode) {
    // Alert user by Dialog or any other layout that you want.
    // When user press OK you must need to call below method.
    permissionInterface.onDialogShown();
  }

  @Override
  public void onShowSettings(PermissionInterface permissionInterface, int requestCode) {
    // Alert user by Dialog or any other layout that you want.
    // When user press OK you must need to call below method.
    // It will open setting screen.
    permissionInterface.onSettingsShown();
  }

This Library support Activity,Fragment and SupportFragment.

 new AskPermission.Builder(/* android.app.Activity */)
 new AskPermission.Builder(/* android.app.Fragment */)
 new AskPermission.Builder(/* android.support.v4.app.Fragment */)
Comments
  • do action after permission granted

    do action after permission granted

    after get permission and granted permission i can show Log on onPermissionsGranted method, and it doesnt work

    public class FragmentAboutUs extends Fragment implements PermissionCallback, ErrorCallback {
        ...
        private int WRITE_EXTERNAL_STORAGE = 1;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
        }
    
        @Override
    
        public View onCreateView(LayoutInflater inflater, final ViewGroup container,
                                 Bundle savedInstanceState) {
            View view = inflater.inflate(R.layout.fragment_about_us, container, false);
    
            ...
    
            //@formatter:off
                about_us_title        = (TextView)   view.findViewById(R.id.about_us_title);
                about_us_description  = (TextView)   view.findViewById(R.id.about_us_description);
                about_us_image        = (ImageView)  view.findViewById(R.id.about_us_image);
            //@formatter:on
    
            aboutUs = SQLite.select().from(AboutUs.class).querySingle();
            if (aboutUs == null) {
                if (ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    new AskPermission.Builder(this).setPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE,
                            Manifest.permission.WRITE_EXTERNAL_STORAGE)
                            .setCallback(this)
                            .setErrorCallback(this)
                            .request(WRITE_EXTERNAL_STORAGE);
                } else {
                    taskManager.addJobInBackground(new TaskGetAboutUsInformation(UUID.randomUUID().toString()));
                }
            } 
    
            return view;
        }
        ...
    
        @Override
        public void onShowRationalDialog(PermissionInterface permissionInterface, int requestCode) {
            permissionInterface.onDialogShown();
        }
    
        @Override
        public void onShowSettings(PermissionInterface permissionInterface, int requestCode) {
    
        }
    
        @Override
        public void onPermissionsGranted(int requestCode) {
            Log.e("onPermissionsGranted","");
        }
    
        @Override
        public void onPermissionsDenied(int requestCode) {
            Log.e("onPermissionsDenied","");
        }
    }
    
    opened by pishguy 9
  • My Application crash on resume

    My Application crash on resume

    when i trying to use this library, i dont have any problem on opening application on first time, but after change permission on android setting and reopen paused application i get this error:

    Caused by: java.lang.IllegalAccessException: void com.kishan.askpermission.ShadowFragment.<init>() is not accessible from java.lang.Class<android.app.Fragment>

    My code:

        public void onCreate(@Nullable Bundle savedInstanceState) {
            if (Build.VERSION.SDK_INT >= 21) {
                getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
            }
    
            super.onCreate(savedInstanceState);
    
            context = getBaseContext();
            alachiq = (Alachiq) getApplication();
            handler = new Handler();
            activity = ActivityRegister.this;
    
            /** Set connection Listener */
            setRealTimeConnectionListener(this);
    
            binding = DataBindingUtil.setContentView(this, R.layout.activity_register);
            ActivityRegisterPresenter presenter = new ActivityRegisterPresenter(this);
    
            binding.setPresenter(presenter);
            int hasPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS);
            if (hasPermission == PackageManager.PERMISSION_GRANTED) {
                attachFragmentsToRegisterUser();
            }else{
                new AskPermission.Builder(this).setPermissions(Manifest.permission.READ_CONTACTS,
                    Manifest.permission.READ_CONTACTS)
                    .setCallback(this)
                    .setErrorCallback(this)
                    .request(READ_CONTACTS);
            }
        }
    
    opened by pishguy 2
  • onPermissionsGranted called twice

    onPermissionsGranted called twice

    Hi, after requesting permision for Camera and Write External Storage, the function onPermissionsGranted is executed two times.

    public void reqPermission() {
            new AskPermission.Builder(this).setPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, android.Manifest.permission.CAMERA)
                    .setCallback(this)
                    .setErrorCallback(this)
                    .request(REQUEST_PERMISSIONS);
        }
    
    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_new_post);
            recognized = (TextView) findViewById(R.id.recognized);
            if (savedInstanceState != null) {
                imageUri = Uri.parse(savedInstanceState.getString(SAVED_INSTANCE_URI));
                recognized.setText(savedInstanceState.getString(SAVED_INSTANCE_RESULT));
            }
    
            detector = new TextRecognizer.Builder(getApplicationContext()).build();
            myBeerDetector = new MyBeerDetector(detector);
    
    //        myBeerDetector.setProcessor(/* include your processor here */);
    
            if (savedInstanceState == null)
                mCameraSource = new CameraSource.Builder(this, myBeerDetector)
                        .setAutoFocusEnabled(true)
                        .build();
    
            // Initialize de DB.
            mDatabase = FirebaseDatabase.getInstance().getReference();
    
            reqPermission();
    
        }
    
        @Override
        public void onPermissionsGranted(int requestCode) {
            if (requestCode == PHOTO_REQUEST)
                takePicture();
        }
    
        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            if (requestCode == PHOTO_REQUEST && resultCode == RESULT_OK) {
                textRecognize();
    
                new QueryWordsTask().execute(words, null, null);
            }
        }
    
        private void takePicture() {
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            File photo = new File(Environment.getExternalStorageDirectory(), "picture.jpg");
            imageUri = FileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".provider", photo);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
            startActivityForResult(intent, PHOTO_REQUEST);
        }
    

    Any idea why it happens? Thanks!

    opened by alexxgarci 1
  • - Application is crash, if user deny the requested permission. This hap…

    - Application is crash, if user deny the requested permission. This hap…

    …pen second time when we try to request.

    • After investigation found that getActivity in alert dialog is returning null, that is due of eariler call of the remove fragment.
    • Before open the Alert Dialog, it wil remove the fragment from the transaction manager, then close the dialog will try to open the settings screen that could't found the fragment attached.
    • Fixed by stop calling the onRequestPermissionDenined().
    opened by Bhavdip 1
  • [ImgBot] Optimize images

    [ImgBot] Optimize images

    Beep boop. Your images are optimized!

    Your image file size has been reduced by 6% 🎉

    Details

    | File | Before | After | Percent reduction | |:--|:--|:--|:--| | /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png | 10.24kb | 9.45kb | 7.73% | | /app/src/main/res/mipmap-xxhdpi/ic_launcher.png | 7.54kb | 7.04kb | 6.66% | | /app/src/main/res/mipmap-xhdpi/ic_launcher.png | 4.73kb | 4.46kb | 5.76% | | /app/src/main/res/mipmap-hdpi/ic_launcher.png | 3.34kb | 3.24kb | 2.90% | | /app/src/main/res/mipmap-mdpi/ic_launcher.png | 2.15kb | 2.10kb | 2.40% | | | | | | | Total : | 28.00kb | 26.28kb | 6.12% |


    📝docs | :octocat: repo | 🙋issues | 🏅swag | 🏪marketplace

    opened by imgbot[bot] 0
  • waffle.io Badge

    waffle.io Badge

    Merge this to receive a badge indicating the number of issues in the ready column on your waffle.io board at https://waffle.io/Kishanjvaghela/Ask-Permission

    This was requested by a real person (user Kishanjvaghela) on waffle.io, we're not trying to spam you.

    opened by waffle-iron 0
  • using Ask-Permission with Asynctask in MainActivity.java

    using Ask-Permission with Asynctask in MainActivity.java

    hello, i've been trying to use this library within Asynctask method but the app didn't show askpermission menu. is the library itself compatible with Asynctask? If so, can you give some code examples to solve this problem?

    opened by Jokurilism 0
  • Crash: v13 support libraries missing when using `exclude group: 'com.android.support'`

    Crash: v13 support libraries missing when using `exclude group: 'com.android.support'`

    https://github.com/Kishanjvaghela/Ask-Permission/blob/master/askpermission/src/main/java/com/kishan/askpermission/ShadowFragment.java#L7

    IntelliJ highlights "app" as red.

    https://github.com/Kishanjvaghela/Ask-Permission/blob/master/askpermission/src/main/java/com/kishan/askpermission/ShadowFragment.java#L52

    When running the app, when I try requesting permissions it crashes with:

    java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v13/app/ActivityCompat;


    My module-level build.gradle contains:

    android {
        defaultConfig {
        compileSdkVersion 28
            minSdkVersion 19
            targetSdkVersion 28
    ...
    dependencies {
        implementation('com.kishan.askpermission:askpermission:1.0.3', {
            exclude group: 'com.android.support'
        })
    ...
    

    I think I know what went wrong. https://github.com/Kishanjvaghela/Ask-Permission#how-to-use tells me to exclude group: 'com.android.support', but this causes the v13 support library to never get downloaded. I'm not sure how to fix the documentation to warn of this issue...


    Also it seems that https://developer.android.com/reference/android/support/v13/app/ActivityCompat is deprecated:

    This class was deprecated in API level 27.1.0. Use android.support.v4.app.ActivityCompat.

    opened by nyanpasu64 4
  • Source code spelling: Rational when you mean Rationale

    Source code spelling: Rational when you mean Rationale

    While reading the source code around https://github.com/Kishanjvaghela/Ask-Permission/blob/0b8874b33a75cdacb85a831fcf274f6eaa3df735/askpermission/src/main/java/com/kishan/askpermission/AskPermissionImp.java#L52 to understand your behavior around PackageManager.PERMISSION_GRANTED, I noticed that you misspell "rationale" as "rational", mainly in the term "showRationalDialog". These words have different meanings.

    This word was confusing for me, as I thought "RationalDialog" meant "logical dialog" (well, I had no clue what was a logical dialog) instead of "reasons for requesting".

    opened by nyanpasu64 1
  • Location not updated on permission granted

    Location not updated on permission granted

    Hello i am developing with google maps, so after requesting the location permissions, i get "permission granted" for first time, but the apps freezes doesn't make anything else. if i re open it it takes the location updates. the problem is on permission granted

    opened by juanjoserodrigolazaro 1
  • Manifest merger failed with multiple errors, see logs

    Manifest merger failed with multiple errors, see logs

    Error:Execution failed for task ':app:processDebugManifest'.

    Manifest merger failed with multiple errors, see logs although I have added like compile('com.kishan.askpermission:askpermission:1.0.3', { exclude group: 'com.android.support' })

    opened by abunayem 0
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
Ask Permission - Simple RunTime permission manager

Ask Permission https://kishanjvaghela.github.io/Ask-Permission/ Simple RunTime permission manager How to use Add url to your gradle file compile 'com.

Kishan Vaghela 77 Nov 18, 2022
Annotation based simple API flavored with AOP to handle new Android runtime permission model

Let Annotation based simple API flavoured with AOP to handle new Android runtime permission model. If you check Google's Samples about the new permiss

Can Elmas 530 Nov 25, 2022
Runtime Mobile Security (RMS) 📱🔥 - is a powerful web interface that helps you to manipulate Android and iOS Apps at Runtime

Runtime Mobile Security (RMS) ?? ?? by @mobilesecurity_ Runtime Mobile Security (RMS), powered by FRIDA, is a powerful web interface that helps you to

Mobile Security 2k Dec 20, 2022
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

Lin Guo 2.9k Dec 28, 2022
LocationPhoneMode - The app will ask the user to allow it to track the user location

LocationPhoneMode The app will ask the user to allow it to track the user locati

null 1 Jan 11, 2022
MinutesAliveApp - Basic Android App that ask for your date of birth and shows your age in minutes

MinutesAliveApp Basic Android App that ask for your date of birth and shows your

JestorDev 0 Jan 30, 2022
AndroidPermissions 4.2 0.0 Java Android M was added to check Permission. but Permission check processing is so dirty.

Android Permissions Checker Android M was added to check Permission. but Permission check processing is so dirty. This Project is to be simple, Checki

Steve SeongUg Jung 340 Nov 11, 2022
Location-permission-handler - Location Permission Handler For Android

Location Permission Handler Easy way to check location permissions for Android 9

null 1 Feb 1, 2022
Attendance-Manager - Attendance Manager, a attendance recording app that helps stay at your 75% attendance

Android-Study-Jams Attendance tracker app Problem Statement: There has been a ne

Gdsc_JMI 1 Jan 9, 2022
[] A simple way to "badge" any given Android view at runtime without having to cater for it in layout

Android ViewBadger A simple way to "badge" any given Android view at runtime without having to cater for it in layout. Note: If your aim is to replica

Jeff Gilfelt 3k Nov 28, 2022
A sample code taking picture in android with app permission and simple ui

Android Taking Picture Sample Just sample code taking picture in android with ap

M. Hafizh Anbiya 2 Dec 29, 2021
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

PermissionsDispatcher 11.1k Jan 2, 2023
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
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

Kosh Sergani 1.2k Dec 14, 2022
🍼Debug Bottle is an Android runtime debug / develop tools written using kotlin language.

???? 中文 / ???? 日本語 / ???? English ?? Debug Bottle An Android debug / develop tools written using Kotlin language. All the features in Debug bottle are

Yuriel Arlencloyn 846 Nov 14, 2022
Runtime code generation for the Java virtual machine.

Byte Buddy runtime code generation for the Java virtual machine Byte Buddy is a code generation and manipulation library for creating and modifying Ja

Rafael Winterhalter 5.3k Jan 7, 2023
🍼Debug Bottle is an Android runtime debug / develop tools written using kotlin language.

???? 中文 / ???? 日本語 / ???? English ?? Debug Bottle An Android debug / develop tools written using Kotlin language. All the features in Debug bottle are

Yuriel Arlencloyn 846 Nov 14, 2022
This library uses OpenGL Shaders to apply effects on Videos at Runtime

VidEffects This is an Android library which can be used to apply different Filters/Effects on videos. It uses vertexShaders and fragmentShaders to app

Sheraz Ahmad Khilji 332 Nov 10, 2022