Does ACCESS_FINE_LOCATION permission include ACCESS_COARSE_LOCATION permissons - java

Good day i was wondering if the user grants an application access to the ACCESS_FINE_LOCATION permission if that application would also automatically have access to the ACCESS_COARSE_LOCATION API methods

As you can see in the LocationManager API and in an older version of the guide:
If you are using both NETWORK_PROVIDER and GPS_PROVIDER, then you need
to request only the ACCESS_FINE_LOCATION permission, because it
includes permission for both providers. (Permission for
ACCESS_COARSE_LOCATION includes permission only for NETWORK_PROVIDER.)
In short: yes, you are allowing to ACCESS_COARSE_LOCATION if you've already defined ACCESS_FINE_LOCATION.

Related

Why WRITE_CONTACTS permission is granted without request?

I have 2 devices with API 28 and an app which needs WRITE_CONTACTS permission. I have added it in manifest <uses-permission android:name="android.permission.WRITE_CONTACTS" />. In the list of contacts in my app, when user click on delete contact, I have made a check to see if there is a permission and request if not. So, in 1st device the method
public static boolean checkWriteContactsPermission(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return true;
}
return ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_CONTACTS) == PackageManager.PERMISSION_GRANTED;
}
return true, at the same time on the 2nd device it reutrns false. I don`t request this permission earlier. Why does it work differently?
Android Permissions are divided into Permission groups, WRITE_CONTACTS is a part of the Contacts permission group.
if you've already asked for another permission in that same group, you are actually granted permissions for the entire group.
So if you've already asked for, and been granted permission for READ_CONTACTS, you'll get WRITE_CONTACTS for free.
But groups may change between different Android versions, see this part in the linked docs:
If the app has already been granted another dangerous permission in
the same permission group, the system immediately grants the
permission without any interaction with the user. For example, if an
app had previously requested and been granted the READ_CONTACTS
permission, and it then requests WRITE_CONTACTS, the system
immediately grants that permission without showing the permissions
dialog to the user.
And then:
Caution: Future versions of the Android SDK might move a particular
permission from one group to another. Therefore, don't base your app's
logic on the structure of these permission groups.
For example, READ_CONTACTS is in the same permission group as
WRITE_CONTACTS as of Android 8.1 (API level 27). If your app requests
the READ_CONTACTS permission, and then requests the WRITE_CONTACTS
permission, don't assume that the system can automatically grant the
WRITE_CONTACTS permission.

The SYSTEM_ALERT_WINDOW permission is not provided automatically after publishing to the Play Store

According to this post, after publishing in Play Store for Android 6 device the SYSTEM_ALERT_WINDOW permission has to be given automatically.
Here it's shown that my App has permission to draw over other apps.
But after downloading from Play Store it is not provided automatically.
I have announced SYSTEM_ALERT_WINDOW only in AndroidManifest.xml
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
What else can I do to make users receive the SYSTEM_ALERT_WINDOW permission automatically after downloading the app from an app store? Is there any chance that the Play Store will block me and not grant the ability to get the permission automatically?

in android studio, while debugging the app BluetoothLeGatt i got the following expectation:

In Android Studio, while debugging the app BluetoothLeGatt, I got the following exception:
Caught a RuntimeException from the binder stub implementation.
java.lang.SecurityException: Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to get scan results
at android.os.Parcel.readException(Parcel.java:1684)
at android.os.Parcel.readException(Parcel.java:1637)
at android.bluetooth.IBluetoothGatt$Stub$Proxy.startScan(IBluetoothGatt.java:678)
at android.bluetooth.le.BluetoothLeScanner$BleScanCallbackWrapper.onClientRegistered(BluetoothLeScanner.java:367)
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:56)
at android.os.Binder.execTransact(Binder.java:565)
You are missing the android.permission.ACCESS_FINE_LOCATION permission in your Manifest and in your code if you are targeting Android 23 or higher.
Add that permission to manifest.xml as well as your code.
This page explains all you need to know about permissions in your Android app.

Requesting Permissions & Permission Group

As per Android Guideline user need grant permission if they have device with android version Marshmallow and up. I have followed instruction given here for my application.
I have declared two permission in my application called WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE in my manifest file. I am little confused in
Permission Group
I have asked permission of WRITE_EXTERNAL_STORAGE, I still need ask permission READ_EXTERNAL_STORAGE or it may automatic granted when user grant WRITE_EXTERNAL_STORAGE permission ?

How to display permission request with api 14

I need to display request permission (Read external storage) at run time. without the permission my app crash instantly.
In API 14 you don't need to do a request.
Just put in your manifest above <application> section:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Requesting permissions at run time is not supported with API level 14, it isn't supported until API level 23.
If you're running your app from Android Studio on a device or emulator where the app is already installed, your app will not ask for permission when it runs. If you inadvertently remove the permission you will need to manually grant the permission through the Application Manager on the device or emulator.
To prevent the initial crash, you could wrap the offending call in a permissions check.
if (ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.READ_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED) {
// READ DATA
}
Hope this helps!

Categories