Code Monkey home page Code Monkey logo

android-permissions's People

Contributors

nishkarsh avatar stromme-grammarly avatar zimmi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-permissions's Issues

Callbacks not working in foreground service

The callbacks (permission denied / granted) don't seem to work in a foreground service in Android API 29. The permission prompt shows up, but callbacks don't fire. Used the code from the Readme and it works when I place it in my MainActivity but it doesn't work in the foreground service.

Can't add dependency

Bug Report

  • Steps to reproduce the problem (include logs and/or sample code where appropriate):

Add dependency to gradle file

  • Error behavior:

Error:failed linking references. (and more messages that have parts of my own package names)

  • Android API Version: Android 7.1.1
  • Android Device (include Model and Manufacturer): Ticwatch
  • Link to sample code (not always needed):

If I remove that dependency again, everything works as before. So this dependency is messing up the build. I can't explain it any better, this is my first experience with Android programming.

Logging occasional ConcurrentModificationException errors

My crash reporting tools are logging dozens of ConcurrentModificationException exceptions related to this library (2.0.49). Reports are from various devices including different Samsung, Google, OnePlus, and Xiaomi models. The consistent factor does appear to be that all devices appear to be running Android 10. Unfortunately all I can offer is the raw error output, as I am unable to reproduce the error myself. The log output is identical on all devices except some line numbers for the OS methods are slightly different. Here is an example from a Google device:

java.util.ConcurrentModificationException
 at java.util.HashMap$HashIterator.nextNode (HashMap.java:1441)
 at java.util.HashMap$KeyIterator.next (HashMap.java:1465)
 at com.intentfilter.androidpermissions.PermissionHandler.informPermissionsGranted (PermissionHandler.java:114)
 at com.intentfilter.androidpermissions.PermissionHandler.onPermissionsResult (PermissionHandler.java:56)
 at com.intentfilter.androidpermissions.PermissionManager.onReceive (PermissionManager.java:60)
 at androidx.localbroadcastmanager.content.LocalBroadcastManager.executePendingBroadcasts (LocalBroadcastManager.java:313)
 at androidx.localbroadcastmanager.content.LocalBroadcastManager$1.handleMessage (LocalBroadcastManager.java:121)
 at android.os.Handler.dispatchMessage (Handler.java:107)
 at android.os.Looper.loop (Looper.java:214)
 at android.app.ActivityThread.main (ActivityThread.java:7356)
 at java.lang.reflect.Method.invoke (Method.java)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492)
 at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:930)

Question: Is this library published?

Hi, this isn't a bug, just a question. I can't find this library in maven central or bintray. Do you publish this library anywhere so that we can consume it without having to download and build the source?

Thanks!

Notification channel not registered on API27

Bug report

If PermissionManager is called when app is in foreground everything works ok - dialog is show.

But when app is in background, no notification is shown (and according to docs:
In case permissions are not yet provided, user would be asked for permissions (a dialog in case app is in foreground, a notification in case it's in background)) it should.

Instead following error is found in adb log:

NotificationService: No Channel found for pkg=xxx, channelId=android-permissions, id=-1951610903, tag=[android.permission.ACCESS_FINE_LOCATION, android.permission.ACCESS_COARSE_LOCATION], ...)

The reason is that this plugin is using channels, but not registering them with NotificationManager. createNotificationChannel

  • Steps to reproduce the problem
    Call PermissionManager checkPermissions when app is in background

  • Expected behavior:
    Notification should shown with Allow action

  • Android API Version:
    API 27 (Oreo)

  • Android Device (include Model and Manufacturer):
    any

  • Link to sample code (not always needed):

Api not adjusted to android-31 target.

Crash on android-31 target

Fatal Exception: java.lang.IllegalArgumentException: com.xxxxxxxx.apps.xxxxxxx: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
       at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
       at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
       at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
       at com.intentfilter.androidpermissions.PermissionManager.notificationDismissIntent(PermissionManager.java:105)

How do i test from Activity for onPermissionDenied() it cannot be invoked. i cannot make an object of PermissionHandler class

For any issues that you report in the android-permissions library, please use this format:

Bug Report

Providing detailed feedback would help in quickly resolving the issue. Following the below format would ensure that enough detail is provided so that the valid bug can be reproduced easily.

  • Steps to reproduce the problem (include logs and/or sample code where appropriate):
  • Expected behavior:
  • Android API Version:
  • Android Device (include Model and Manufacturer):
  • Link to sample code (not always needed):

Using FLAG_ACTIVITY_NEW_TASK instead of notification

Hello!
I really liked your library and I would really love if there were a function like checkPermissions(...), but that instead of using a notification, would open the permissions activity using intent.FLAG_ACTIVITY_NEW_TASK.
I am developing a keyboard so I do kind of running on the foreground even though my service isn't an activity.

Thanks anyway!

Add ability to provide custom/app icon for the status bar notification

Hello! Thanks for the library!

As a developer, I would like to have the ability to use my own app logo/icon for the status bar notification. Right now it's using the default android icon, which is OK, but I think we can do better.

I believe this part

 Builder notificationBuilder = (new Builder(this.context, "android-permissions")).setContentTitle(title).setContentText(message).setAutoCancel(true).setPriority(0).setSmallIcon(17629184).setContentIntent(pendingIntent);

needs to be updated with an option to use provided icon

Thank you!

Project should be moved off jcenter repository

The JCenter repository is shutting down and Android Studio now displays a warning when including dependencies that access it. It appears that android-permissions is hosted on JCenter and will need to be moved to allow future updates and prevent this warning.

From https://developer.android.com/studio/build/jcenter-migration:

"JFrog, the company that maintains the JCenter artifact repository used by many Android projects, made JCenter a read-only repository on March 31st, 2021. According to the announcement, JCenter will allow downloads of existing artifacts indefinitely.

Developers who publish artifacts on JCenter should migrate their packages to a new host, such as Maven Central.

Developers who use dependencies from JCenter will need to find the new location of updated versions of those dependencies."

Switch to AndroidX

Thank you for this amazing library, it helps escaping the tyranny of the activity lifecycle!

I'm using android.useAndroidX=true and android.enableJetifier=true in the gradle.properties of my app which leads to an exception (see below). To avoid this, I had to add implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' to my gradle.build file.

Because AndroidX replaces the now unmaintained Support Library, I think the time is right to switch to AndroidX, adding the correct localbroadcastmanager-dependency to android-permissions while doing so. Would you accept a PR doing this?

I see that LocalBroadcastManager itself is deprecated, but there is no direct replacement and the AndroidX version isn't going anywhere, so I'd leave the code alone for now, just add the dependency.

The original exception:

2019-10-27 17:40:29.273 28731-28731/org.example.myapp E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.example.myapp, PID: 28731
    java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/localbroadcastmanager/content/LocalBroadcastManager;
        at com.intentfilter.androidpermissions.PermissionManager.registerBroadcastReceiver(PermissionManager.java:90)
        at com.intentfilter.androidpermissions.PermissionHandler.registerForBroadcastIfNeeded(PermissionHandler.java:130)
        at com.intentfilter.androidpermissions.PermissionHandler.checkPermissions(PermissionHandler.java:46)
        at com.intentfilter.androidpermissions.PermissionManager.checkPermissions(PermissionManager.java:53)
        at org.example.myapp.LocationLiveData.onActive(MainViewModel.kt:50)
        at androidx.lifecycle.LiveData$ObserverWrapper.activeStateChanged(LiveData.java:437)
        at androidx.lifecycle.LiveData$LifecycleBoundObserver.onStateChanged(LiveData.java:395)
        at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:361)
        at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:300)
        at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:339)
        at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:145)
        at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:131)
        at androidx.lifecycle.ReportFragment.dispatch(ReportFragment.java:129)
        at androidx.lifecycle.ReportFragment.dispatch(ReportFragment.java:205)
        at androidx.lifecycle.ReportFragment.onStart(ReportFragment.java:170)
        at android.app.Fragment.performStart(Fragment.java:2548)
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1334)
        at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1576)
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1637)
        at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3046)
        at android.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:3003)
        at android.app.FragmentController.dispatchStart(FragmentController.java:193)
        at android.app.Activity.performStart(Activity.java:7165)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:2952)
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1823)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:198)
        at android.app.ActivityThread.main(ActivityThread.java:6729)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.localbroadcastmanager.content.LocalBroadcastManager" on path: DexPathList[[zip file "/data/app/org.example.myapp-LZugZ-nCgbUhyoEE1G9AWA==/base.apk"],nativeLibraryDirectories=[/data/app/org.example.myapp-LZugZ-nCgbUhyoEE1G9AWA==/lib/arm64, /data/app/org.example.myapp-LZugZ-nCgbUhyoEE1G9AWA==/base.apk!/lib/arm64-v8a, /system/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.intentfilter.androidpermissions.PermissionManager.registerBroadcastReceiver(PermissionManager.java:90) 
        at com.intentfilter.androidpermissions.PermissionHandler.registerForBroadcastIfNeeded(PermissionHandler.java:130) 
        at com.intentfilter.androidpermissions.PermissionHandler.checkPermissions(PermissionHandler.java:46) 
        at com.intentfilter.androidpermissions.PermissionManager.checkPermissions(PermissionManager.java:53) 
        at org.example.myapp.LocationLiveData.onActive(MainViewModel.kt:50) 
        at androidx.lifecycle.LiveData$ObserverWrapper.activeStateChanged(LiveData.java:437) 
        at androidx.lifecycle.LiveData$LifecycleBoundObserver.onStateChanged(LiveData.java:395) 
        at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:361) 
        at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:300) 
        at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:339) 
        at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:145) 
        at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:131) 
        at androidx.lifecycle.ReportFragment.dispatch(ReportFragment.java:129) 
        at androidx.lifecycle.ReportFragment.dispatch(ReportFragment.java:205) 
        at androidx.lifecycle.ReportFragment.onStart(ReportFragment.java:170) 
        at android.app.Fragment.performStart(Fragment.java:2548) 
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1334) 
        at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1576) 
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1637) 
        at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3046) 
        at android.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:3003) 
        at android.app.FragmentController.dispatchStart(FragmentController.java:193) 
        at android.app.Activity.performStart(Activity.java:7165) 
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:2952) 
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180) 
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165) 
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1823) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:198) 
        at android.app.ActivityThread.main(ActivityThread.java:6729) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

Crash when permissions denied

Hi,

I am using an npm plugin that uses android-permissions 0.1.8

When permissions are denied, my app crashes at PermissionHandler.java:102

I can see that your library has been developed well past 0.1.8

Has this bug already been fixed?

Can you give me the lowest version number at which it is fixed?

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.okappy.okappy, PID: 28732
    java.lang.AbstractMethodError: abstract method "void com.intentfilter.androidpermissions.PermissionManager$PermissionRequestListener.onPermissionDenied(com.intentfilter.androidpermissions.models.DeniedPermissions)"
        at com.intentfilter.androidpermissions.PermissionHandler.informPermissionsDenied(PermissionHandler.java:102)
        at com.intentfilter.androidpermissions.PermissionHandler.onPermissionsResult(PermissionHandler.java:57)
        at com.intentfilter.androidpermissions.PermissionManager.onReceive(PermissionManager.java:60)

Thank you in advance for any help you are able to give me.

Robin

Callback onPermissionGranted called, but permision is not granted

On create() I have this part of code:

 PermissionManager permissionManager = PermissionManager.getInstance(this);
         permissionManager.checkPermissions(singleton(Manifest.permission.USE_FINGERPRINT), new PermissionManager.PermissionRequestListener() {
             @Override
             public void onPermissionGranted() {
                 Toast.makeText(getBaseContext(), "Permissions Granted", Toast.LENGTH_SHORT).show();
                 fingerprintCheckBox.setEnabled(true);
 
             }
 
             @Override
             public void onPermissionDenied() {
                 Toast.makeText(getBaseContext(), "Permissions Denied", Toast.LENGTH_SHORT).show();
             }
         });

But when I check if the permission is granted:

if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED)

it returns FALSE.

Add ability to set color of notification

Hello!

Love that the latest release supports setting the notification icon. Would you consider adding support for setting the color as well? It appears that this could be done when setting up the Builder in NotificationService.java and exposed to the API caller similarly to .withSmallIcon().

     NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, CHANNEL_ID)
                .setContentTitle(title)
                .setContentText(message)
                .setAutoCancel(true)
                .setPriority(NotificationCompat.PRIORITY_DEFAULT)
                .setSmallIcon(smallIconResId)
                .setContentIntent(pendingIntent);

Thanks!

Andrew

application@allowBack is required by the plugin

Does this library use the application attribute allowBackup

Can it be removed?

Implementing the library in an App which also defines this attribute requires some tools:replace fiddling:

/app/src/main/AndroidManifest.xml:11:7-34 Error:
        Attribute application@allowBackup value=(false) from AndroidManifest.xml:11:7-34
        is also present at [com.intentfilter:android-permissions:0.1.5] AndroidManifest.xml:12:9-35 value=(true).
        Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:7:5-24:19 to override.

Using checkPermissions() prompts for first request, but not subsequent requests received while waiting for user

Using checkPermissions(), if there is a pending prompt for one permission, and request(s) for other permission(s) arrive, the user is never prompted for the additional permission(s) until the app restarts. Looking at logcat output, it appears that the library believes there is still a pending request for the second permission but that prompt is never shown to the user.

For example, upon launching my app, it asks for ACCESS_COARSE_LOCATION almost immediately. Within a short period of time (less than a second), READ_PHONE_STATE typically becomes needed by another method. In this instance, ACCESS_FINE_LOCATION was also requested. The user gets the location permission prompt, but the phone permission prompt never appears unless you shut down and restart the app. Logcat output attached with comments:

logcat.txt

NPE on runningAppProcesses iterator() in AppStatus.isInForeground() method

Bug Report

  • Steps to reproduce the problem (include logs and/or sample code where appropriate):
    N/A crash from crashlitics:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference
       at com.intentfilter.androidpermissions.helpers.AppStatus.isInForeground(AppStatus.java:18)
       at com.intentfilter.androidpermissions.PermissionHandler.requestPermissions(PermissionHandler.java:74)
       at com.intentfilter.androidpermissions.PermissionHandler.checkPermissions(PermissionHandler.java:50)
       at com.intentfilter.androidpermissions.PermissionManager.checkPermissions(PermissionManager.java:52)
       at com.x.x.x.PermissionsHelper.checkPermissions(PermissionsHelper.java:32)
//FIX
if (runningAppProcesses == null) 
    return false 

How to grant multiple permissions at once in singleton place.

For any issues that you report in the android-permissions library, please use this format:

Bug Report

Providing detailed feedback would help in quickly resolving the issue. Following the below format would ensure that enough detail is provided so that the valid bug can be reproduced easily.

  • Steps to reproduce the problem (include logs and/or sample code where appropriate):
  • Expected behavior:
  • Android API Version:
  • Android Device (include Model and Manufacturer):
  • Link to sample code (not always needed):

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.