Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 126.96.36.199 release ready!
Owner and Founder. Opencart
As the new changes are being done for the better privacy of the user Android has updated the permission policy for location access. Android restricts its usage, especially in the background.
Before Android 9, there was no separate location permission for the Foreground and background apps therefore they were using the same resources due to this some of the apps were exploiting the location data of the users.
On Android 11 and higher, whenever your app requests access to the foreground location, the system permissions dialog includes an option called Only this time. This option gives users more control over when an app can access location information.
There are now two options available for the developer to pick from:
1: Foreground Location.
2: Background Location.
When you are developing an app that requires only that share or receives location information only one time, or for a specific amount of time then, that feature requires foreground location access.
To achieve this, we need to add the uses permission tag in the Android Manifest file.
From Android 11, the users now have 3 options to give access to their location:
1: While using the app
2: Only this time
To know the permission added on the Android manifest file are:
ACCESS_COARSE_LOCATION: Provides an estimate of the device location, within about 1 mile (1.6 km).
ACCESS_FINE_LOCATION: Provides an estimate of the device’s location as accurately as possible, usually within about 160 feet (50 meters) and sometimes as accurate as within 10 feet (a few meters) or better.
To get the current location using the foreground location with the help of an example.
An app requires background location access if a feature within the app constantly shares a location with other users or uses the Geofencing API. Like sharing your live location.
From Android 10 (API level 29) and higher API level, you must have to declare the ACCESS_BACKGROUND_LOCATION permission in your app’s manifest to request background location access at runtime, otherwise, the system will ignore it. On earlier versions of Android, when your app receives foreground location access, it automatically receives background location access as well.
The second one is that the application needs to use location also in the background. For which you have to create a dialog with a precise message to explain the use of background location.
After the user agrees, redirect to the application’s setting page where you can choose the permission type as given below.
1: Allow all the time.
2: Allow only while using the app.
3: Ask every time
Now how to ask for the background location permission in code here is the below example.
You can call the backgroundLocationPermission() method on the button click if you want, like the below code.
I have used a simple layout design.
You can also check out the official documentation provided by Google click here.
. . . . . . . . .
That’s it from my side for today, thanks for reading it until now. You can check our other android blogs Click Here.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Excellent work, fast, good quality and understood the brief perfectly! Quick responses developing the project and very good cooperation. I suggest to anyone.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.