Request Background location permission settings tab in android 11 - java

in android 11 (API 30) you can't request the permission ACCESS_BACKGROUND_LOCATION directly from the requestPermissions() method.. and instead, you need to enable it from the settings.
On the Android Developers website: https://developer.android.com/training/location/permissions
they say you can call getBackgroundPermissionOptionLabel() to get the settings label of the location permission.
The documentation is limited and lacks specification of the getBackgroundPermissionOptionLabel() method and I don't know what to do.
Does anyone know how to use this method?

getBackgroundPermissionOptionLabel() gives you a localized string that you can use to get the label of the option to "Allow all the time".
It is quite hard to request background location permission and dealing with the order of the permissions, rationales, and permanent denials. I would suggest having a look at the library I have been working on for a while for asking for permissions where this is included: https://github.com/warting/permissions-ui

Related

Stop language changes in app after locale changes

I use a runtime permission library called Kpermission to request permission, but the issue is the permission request follows device language and not app language
You can't. Instead of changing better you display your custom dialog before requesting permission to explain you the purpose of permission
You can check this link https://developer.android.com/training/permissions/requesting.html
Note: Your app cannot customize the dialog that appears when you call launch(). To provide more information or context to the user, change your app's UI so that it's easier for users to understand why a feature in your app needs a particular permission. For example, you might change the text in the button that enables the feature.
Also, the text in the system permission dialog references the permission group associated with the permission that you requested. This permission grouping is designed for system ease-of-use, and your app shouldn't rely on permissions being within or outside of a specific permission group.
Example Custom Dialog Permission

How to know that user don't give internet access to our app?

Android system now gives users the decision to give or restrict internet access to selected apps. This is very detrimental to developers, especially for developers that use AdMob and other advertisement services. How to know that users don't give internet access to our app so i can give them warnings?
This is what i mean "Android system now gives users the decision to give or restrict internet access to selected apps":
Internet permission is normal permission in android 12(Which is least preview version of android) too. I don't know what is your problem but if you want to check user's network status, see this document https://developer.android.com/training/basics/network-ops/managing
EDIT
In your case, if turning off switch, android will block network in background. This document will help you https://developer.android.com/training/basics/network-ops/data-saver?hl=en
Forground access will works fine. You're able to access internet switch has been disabled also.

Directly Enable Permission Like Location

I can implement Runtime permission where a dialog appears to the user to allow the permission or deny the permission. But I want The permission will be enabled or allowed in the background without asking the User. Is it possible? is it possible then how to do it? Please explain in Java (Android studio).
in the background without asking the User. Is it possible?
no.
this defeats the point of the permission model - if any random app could just get your location (or any other sensitive permission) without requesting for it, why would apps even bother to implement runtime permissions ?

Android permissions: asking options guide

I apologize in advance for my language and if this thread is a duplicate.
I would like to ask for a 'mini-guide' on android permission asking for 6.0+. The problem that I am personally having is some applications I recently released require permissions like internet and external storage. But the only way I could 'help' the user from going manually to settings -> app settings etc, is launching an intent on button press for the app setting page.
So what I am asking is:
For newest versions of Android (assuming it will work on most older versions too),
is there a way to:
Ask for every permission you need to be accepted before downloading on Play Store and then enabled by default?
Ask on first time app launch to give permanent permissions to app and on positive response, programmatically enable them?
Ask the user for a one-time, dynamic, TEMPORARY, permission request. For example, app1 does not have permission to write to an external storage. On button1 press, ask temporary permission to write to a file in the external storage. If the user clicks button1 again, permission will be asked again.
Again, apologies if this question has been asked before. I want to assure you I did a lot of research, and most of the answers I found didn't seem to work...
Thanks
1) I think its not possible to enable all permissions by default since its a major update in Android 6+ devices to enable users to control runtime permissions the app needed.
For 2 & 3)
For my project I have written a static java class to request android runtime permissions. You can use that if you want. You have to add other permissions as you need in the same pattern as described in the class.
I have provided the Github link below
Github

Android Preference-Specific Permission Requests

Is there a way to request a specific permission only when the user enables a certain preference?
In my case, I have an option to sync with the calendar to add dates and set reminders (to my knowledge, you can't set reminders in the calendar with Intents). Obviously I need permission to access the calendar, but ONLY when the user enables this option. I'd like to, when the user enables the preference, request permission, then disable the option if permission isn't granted.
No. Unfortunately there is no option to do that.
No checks with the user are done while an application is running: it either was granted a particular permission when installed, and can use that feature as desired, or the permission was not granted and any attempt to use the feature will fail without prompting the user.
http://developer.android.com/guide/topics/security/permissions.html
This is possible since Marshmallow. See video showing best practice to ask for permission from Android Marshmallow
You can find snippets of code allowing you to do this at Android developer guide to requesting permission for Marshmallow and above

Categories

Resources