k0shk0sh / permissionhelper Goto Github PK
View Code? Open in Web Editor NEWAndroid Library to help you with your runtime Permissions.
Home Page: http://k0shk0sh.github.io/PermissionHelper/
License: Apache License 2.0
Android Library to help you with your runtime Permissions.
Home Page: http://k0shk0sh.github.io/PermissionHelper/
License: Apache License 2.0
i had read your demo ,but i can't find what difference with using PermissionHelper and without it.
Seems easy enough:
protected void intentCamera()
{
permissionHelper
.setForceAccepting(false)
.request(MULTI_PERMISSIONS); // CAMERA and WRITE_EXTERNAL_STORAGE
showCamera();
}
But doesn't work as expected, as showCamera()
is called regardless of the status of the permissions. Does showCamera()
go into onRequestPermissionsResult()
?
If i disable the permission manually while running the app
(Go to the App Setting -> Disable the permission anything), our activity will have a problem.(Specifically, In a case that activity has fragments). I see that android kills the app in the circumstance.
thank you for this library but how i can make the group request permission like this group
Manifest.permission_group.STORAGE
Hello,
I have checked your code is working perfectly in Nexus 6P
But i have an issue of not press Allow button Properly in Nexus 5
Please check it.
Thanks,
Dixit Patel
Hi,
the function .setSkipExplanation() is not available in v. 1.1.0, but in the Example project it is.
Hallo,
I want showing my Permissions like this. But my code doesn't work. It only show always the first permission of the list. Could you help me pls.
public final static String WRITE_EXTERNAL_STORAGE_PERMISSION = Manifest.permission.WRITE_EXTERNAL_STORAGE;
public final static String ACCESS_FINE_LOCATION_PERMISSION = Manifest.permission.ACCESS_FINE_LOCATION;
public final static String CAMERA_PERMISSION = Manifest.permission.CAMERA;
public final static String[] MULTIPLE_PERMISSIONS = {WRITE_EXTERNAL_STORAGE_PERMISSION,
ACCESS_FINE_LOCATION_PERMISSION,
CAMERA_PERMISSION};
permissionHelper.setForceAccepting(false)
.request(PermissionsStatesHelper.MULTIPLE_PERMISSIONS);
This project is abandoned?
I can use it in my project without problems?
I will be submitting this to github as a public (open source) repo over the next few days as I work in a better webview api (XWalk). But for now, here is working code for a webview which asks for runtime perms for camera or gallery access based on user selected option.
https://gist.github.com/digitalprecision/735820df14f696fc2c6c8b251b2b05d6
Thanks for the api, it definitely helped alleviate a lot of the pain.
For Example:
In an Activity, there are two actions(download, take photos) that request Manifest.permission.WRITE_EXTERNAL_STORAGE.
Before start download action, request the permission, and then the permission is granted.
Now, What to do next? (Notice that taking photos also require and request the permission.)
The next step is to download or to take photos?
I want to show the OS request without showing the explanation message even after the user press decline for the first time.
The uploaded artifacts (source and aar) have the request method in base with the == not the latest >= on the sdk check..
Looks a bit like the wrong artifact got uploaded. the release zip is fine..
Adaptation 8.0 occurs when only the onpermissionpregranting method is called. How does this resolve?
You should provide a parameter in onNoPermissionNeeded method to distinguish multiple permissions callback;
Can you post an example of how to reference an array element from SamplePagerActivity in SampleActivity? I am trying to customize the boxes, but when I call
permissionHelper .setForceAccepting(false) .request(MULTI_PERMISSIONS);
No customizations appear. Just the default alerts.
@k0shk0sh This problem still exists in Android 6.0.1.
I am using v1.0.11 but still not getting expected multiple permissions.. it shows only first permission from list. and if first permission is granted then only it displays next one.. but it is not showing non granted permissions in queue.. as shown in images above by @drchopper
i have tried as said in #10 this issue but dint worked for me
Look at the screenshot.
You vcan see the permission is android.permission.GET_ACCOUNTS
And the PermissionModel is for android.permission.ACCESS_FINE_LOCATION
My PermissionModel is defined like this for testing
List<PermissionModel> permissions = new ArrayList<>();
permissions.add(PermissionModelBuilder.withContext(this)
.withTitle("ACCESS_FINE_LOCATION")
.withCanSkip(false)
.withPermissionName(Manifest.permission.ACCESS_FINE_LOCATION)
.withMessage("PermissionHelper also prevents your app getting crashed if the " +
"requested permission never exists in your AndroidManifest" +
". Android DOES!")
.withExplanationMessage("We need this permission to access to your location to" +
" find nearby restaurants and places you like!")
//.withFontType("my_font.ttf")
.withLayoutColorRes(R.color.primary_color)
.withImageResourceId(R.drawable.logo_image)
.build());
permissions.add(PermissionModelBuilder.withContext(this)
.withTitle("GET_ACCOUNTS")
.withCanSkip(true)
.withPermissionName(Manifest.permission.GET_ACCOUNTS)
.withTitle(R.string.title_get_accounts)
.withMessage(R.string.message_get_accounts)
.withExplanationMessage(R.string.explanation_message_get_accounts)
//.withFontType("my_font.ttf")
.withLayoutColorRes(R.color.primary_color)
.withImageResourceId(R.drawable.logo_image)
.build());
permissions.add(PermissionModelBuilder.withContext(this)
.withTitle("READ_CONTACTS")
.withCanSkip(true)
.withPermissionName(Manifest.permission.READ_CONTACTS)
.withTitle("READ_CONTACTS")
.withMessage(R.string.message_get_accounts)
.withExplanationMessage(R.string.explanation_message_get_accounts)
//.withFontType("my_font.ttf")
.withLayoutColorRes(R.color.primary_color)
//.withImageResourceId(R.drawable.permission_three)
.build());
permissions.add(PermissionModelBuilder.withContext(this)
.withTitle("WRITE_CONTACTS")
.withCanSkip(true)
.withPermissionName(Manifest.permission.WRITE_CONTACTS)
.withTitle("WRITE_CONTACTS")
.withMessage(R.string.message_get_accounts)
.withExplanationMessage(R.string.explanation_message_get_accounts)
//.withFontType("my_font.ttf")
.withLayoutColorRes(R.color.primary_color)
//.withImageResourceId(R.drawable.permission_three)
.build());
permissions.add(PermissionModelBuilder.withContext(this)
.withTitle("WRITE_EXTERNAL_STORAGE")
.withCanSkip(true)
.withTitle("WRITE_EXTERNAL_STORAGE")
.withPermissionName(Manifest.permission.WRITE_EXTERNAL_STORAGE)
.withMessage("PermissionHelper lets you customize all these stuff you are seeing!." +
" if you ever thought of anything that improves the library please" +
" suggest by filling up an issue in github https://github.com/k0shk0sh/PermissionHelper")
.withExplanationMessage("We need this permission to save your captured images and videos to your SD-Card")
//.withFontType("my_font.ttf")
.withLayoutColorRes(R.color.black)
.withImageResourceId(R.drawable.logo)
.build());
permissions.add(PermissionModelBuilder.withContext(this)
.withTitle("SYSTEM_ALERT_WINDOW")
.withCanSkip(false) /*explanation only once will be called otherwise we will
run into infinite request if the user never grant the permission.*/
.withTitle("SYSTEM_ALERT_WINDOW")
.withPermissionName(Manifest.permission.SYSTEM_ALERT_WINDOW)
.withMessage("PermissionHelper handles requesting SYSTEM_ALERT_WINDOW permission")
.withExplanationMessage("We need this permission to make our videoPlayer overlay on your screen.")
//.withFontType("my_font.ttf")
.withLayoutColorRes(R.color.primary_color)
.withImageResourceId(R.drawable.logo_image).build());
return permissions;
Hi,
There's plenty of java code snippets in the README, but none of them declare they are in java, so they don't get syntax coloration and are harder to read as a consequence.
To fix this, you just have to add the language after the first three backticks (so java in this case), as written here
Hey, it would be awesome if you could implement support for android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS. This is similar to the system alert window permission in that you need to go to settings to change it.
My app is closed when I press deny or allow, is there any solution to that?
EDIT: my bad, I've android:noHistory="true" in manifests
Is it possable to get a new release with the change that fixes the version check on the release call?
Just tried my app on android V24 and it failed to popup the permission because of this..
hey im trying to implement your pager example and apparently i didi everything right but and i click the check button a request popup show and not a permission popup mu code is attached could you help me out
Hi,
is it possible to set a request without using the OnPermissionCallback.
Like this:
boolean isGranted = permissionHelper
.setForceAccepting(false)// true if you had like force reshowing the permission dialog on Deny (not recommended)
.request(isSingle ? SINGLE_PERMISSION : MULTIPLE_PERMISSIONS);
if user declined (boolean = false) -> ask next time again
if user really declined (boolean = false) - > open a dialog with "open Settings" buttom
if user granted (boolean = true) - > do nothing
do you know what i mean?
cheers
The slider thing is great but it would be cooll if we can add a slide that does not ask for permission.
atm if i build a slide without calling withPermissionName it crash
java.lang.IllegalArgumentException: Unknown permission: null
Hi,
I have implemented PermissionHelper and rolled out my APK. I tested it with several phones before release, but now I get dozens of crash of my users.
Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'int android.content.Context.checkPermission(java.lang.String, int, int)' on a null object reference
com.fastaccess.permission.base.PermissionFragmentHelper.isPermissionDeclined (PermissionFragmentHelper.java:348)
I use it in Fragments. Maybe context is losing it's state somehow? So we would need to check context for null?! The crash happens only on Android 8 devices. Update: Now I saw it also on Android 7.1.1
How to handle that?
First of all thank you for this great library. However in my app I need to get WRITE_SETTINGS permission and I use following block of code.
permissions.add(PermissionModelBuilder.withContext(this)
.withCanSkip(false)
.withPermissionName(Manifest.permission.WRITE_SETTINGS)
.withTitle("CHANGE BRIGHTNESS SETTINGS")
.withMessage("This permission is required for this app to change brightness settings of this device.")
.withExplanationMessage(R.string.explanation_message_get_settings)
.withFontType("my_font.ttf")
.withLayoutColorRes(R.color.colorPrimary)
.withImageResourceId(R.drawable.permission_three)
.build());
This does not prompt me to get system settings and it simply skip to next page (using SamplePagerActivity).
I have defined uses-permission android:name="android.permission.WRITE_SETTINGS" in Manifest file as well.
Do you have any idea why? Appreciate your help. Thanks.
When I try to request multiple permission and user has already denied them once, it is supposed to call onPermissionNeedExplanation but it doesn't do that but this works fine it I call one permission at a time.
Please fix this issue.
Edit:
Even if I request each permission one by one it shows onPermissionNeedExplanation for only first one and for others it requests permission i.e onPermissionNeedExplanation and permission dialog gets overlapped.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.