Is there a way to automatically accept permissions on a user's mobile and without the interaction of the user with the app? When the app launches, the permissions should be accepted automatically. Please suggest me any idea/hack to do it.
Thanks
Yea its possible , For that you need change targetSdkVersion (SDK v26 or any version above to SDK v22) to targetSdkVersion SDK v22 in build.gradle , in this case it will not ask to user to grant perssion , it will take permission automatically and why its working because granting permission introduce in sdk 23 and above
Note :- it may be ask permission in OPPO phones , Vivo etc while runtime.
Sample Peoject Link :- https://github.com/kdblue/PermissionGranted
No problem if the solution is illegal but I want a way to do it
Whats this mean?
First of all this is impossible. If you are working on a technology then you have to follow its guidelines.
The second thing is if your app targets Android M or greater then you have to follow the Permission model .
If your app target is below Android M then you do not have to ask for Runtime permission, the permissions will automatically granted on installation all at once.
Note:- Starting from Android M User can manually allow/disallow the permission to any third party app . So in that case you won't get SecurityException but your feature would not work .
Conclusion:- As you see your app is going to effect anyhow whether its targets low or high, So its better to follow the Permission model and make use of Android's new version's. As Android's new versions rolls out to more and more users, apps that request permissions at the time of installation will be viewed as un-maintained or poorly written, as users will expect not to have to agree to permissions up front, which leads to bad user experience .
Related
I am developing an app for internal use and it requires some permissions like camera, internet, etc.
In order to make everyone's life easier I am investigating the possibility of auto accepting all these permissions on runtime.
The app will not be published on Play Store and it will only be used by employees on company premises and with company devices, so there is no security risk involved here.
Any ideas? Is this even possible? Hackish solutions work too, doesn't really matter as long as the goal is achieved.
If you're using targetSdkVersion>=23 your app has to request the permissions
If permissions are considered "normal" the system will immediately grant them upon app installation. Other permissions which are considered "dangerous", the user must explicitly grant your app access to them.
If you downgrade the targetSdkVersion to API level 21 , there would be no need to ask permissions , since they will granted during app installation, but still on android devices with OS versions >= 6.0 the user can go to app settings and disable them.
I don't think that you can, and this is why:
If your permission is normal permission it will be auto-granted.
If the device API level is <= 22 / targetSdkVersionis 22 or lower:
In that case, the user will be asked (by the system) in the install time to grant all the dangerous permissions for the app.
If the device API level is > 22 and targetSdkVersion is above 22:
The user will not accept dangerous permissions at install time. You must ask the user to grant access to the dangerous permissions at runtime - when you do ask your user to give access to those permissions on run time he will see system dialog that asks him to accept or decline the permissions.
I don't think that you can do what you want and I think that your best solution is to just ask the users the wanted permissions.
I have created an app which amongs others show the SSID name.
Now with the latest android version, the user needs to set extra permissions (<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />) for my app to be able to get the SSID name.
Now that's all fine, but 1. these permissions are harder to get (I understand that I can't just ask for them but the user has to explicit go to the app-settings and accept the location permission) and, more importantly 2. I don't want to ask for those rights if the user is still on an old(er) version of Android and these extra permissions are not needed.
I have these settings
minSdkVersion 11
targetSdkVersion 26
so also very old Android versions can install my app, and now they also have to give the permission for the Android version they don't yet have?
I would like that only users on the latest version of Android have to give these permission, and users on older Android versions don't have to.
Is it possible to make this distinction in the manifest?
I've seen a reference to Is it available to set checkSelfPermission on minimum SDK < 23? but that question doesn't talk about the manifest xml and that's what my question is about
User won't have to go explicit to the app-settings, just check the Android version with
android.os.Build.VERSION.SDK_INT >= N
And if it is true, you should ask the permission with
Activity.requestPermissions(String[] permissions, int requestCode)
Then listen the result with Activity.onPermissionsResult.
Google allows the permission at run time and it allows the user to allow or deny the permission.
When user installs the app the permissions should automatically be ON, it should not be asked to user.
How can i get this functionality?
Thank you.
It is not possible. If user not allow permission then app cant access resource related to particular permission. It is done by google for security purpose.
When user installs the app the permissions should automatically be ON, it should not be asked to user.
Have a targetSdkVersion below 23. This is not a viable long-term solution, as eventually something will force your hand to have a targetSdkVersion of 23 or higher.
You cite OlaCabs as an example of the behavior that you want. OlaCabs has a targetSdkVersion of 22.
How can I set default permission in marshmallow so that if user sets off the permission manually and again when user opens the app the permission should be ON and the permissions should not be ask to user, it should be directly ON.
That is not possible. For example, with OlaCabs, after installing it but before running it, I revoked its rights to access contacts, location, phone, SMS, and storage. I then ran OlaCabs, and it crashed, because I had revoked its access to location data, and the authors of OlaCabs do not check to see whether they have permission first. OlaCabs does not magically cause those permissions to be re-granted.
It is not possible to do so on marsh mallow, as it is fully based on runtime permissions.It increases users security.Your queries are supported only to Versions below marshmallow.Try having target version as 22 and run your app.
Must I declare all the permissions in the Manifest as before?
I'm asking it for a reason - let's have a scenario that you introduce a new feature to your app that requires the Contacts permission, and let's think about it from a product perspective.
When it comes to Marshmallow users, everything will be okay (concerning UX) - upon update, they won't ask for new permissions, but only the moment of need. That's fine with me.
But, prior Marshmallow users will be requested for the new permission upon update, and may disapprove it, and by that, won't update the app. Not good.
What if I want my new feature to be available only for Marshmallow users and above, while older versions users won't get the feature and be asked for the new permission upon update? Can I do something like this?
Hope I was clear enough.
Must I declare all the permissions in the Manifest as before?
They must be in the manifest, yes.
What if I want my new feature to be available only for Marshmallow users and above, while older versions users won't get the feature and be asked for the new permission upon update? Can I do something like this?
Yes. Use the awkwardly-named <uses-permission-sdk-23> element as a replacement for <uses-permission>. On API Level 22 and older devices, this element will be ignored. On API Level 23+ devices, you can request the permission at runtime as normal.
When you open the camera the user is prompted to grant the app permission to access the camera.
Is there any way in Codename one to tell if the user has denied this permission?
With either a callback or some kind of global call?
This specific to iOS but with the recent updates to Android the same question is also relevant there.
This is now built in to the CodenameOne platform - https://www.codenameone.com/blog/switching-on-android-marshmallow-permission-prompts.html
Currently we haven't enabled the Marshmallow permission prompts by default in part due to the lack of an API to indicate that.
We have a standard API for contacts permissions which we needed in iOS and most of the API's should be ready for Marshmallow since iOS always had the ability to deny permissions.
But we need to re-think the API's for querying that detail and whether we want them to follow the style of isContactsPermissionGranted.
I noticed there is no issue to track the progress of this so I filed it.