How to display permission request with api 14 - java

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!

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.

Is there a path in the Emulator that can be programmatically written when the permission is denied?

In the lower Android version, /sdcard/Download can be read and written, but from Android6 when I use code File file = new File("/sdcard/Download/TestResults.xls"); it will throw exception permission denied, I want to find are there a path in emulator that jave code can directly use to create File without asking permission?
Android-M ie, API 23 introduced Runtime Permissions for reducing security flaws in android device, where users can now directly manage app permissions at runtime.
You should to use permission API version above 23.
Refer this Android marshmallow request permission?

Google play app change permissions

I have uploaded an application to google play, but it doesn't ask for permissions on install for some reason.
I have these permissions in my AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
You can manually add these permissions via settings on the phone, other permissions do not show up, so I guess app is done correctly, though memory permission is disabled by default and user has to manually enable it.
Most likely, your module has its targetSdkVersion set to 23 or higher. In that case, permissions with a protectionLevel of dangerous — such as the two you are requesting — not only have to appear in the manifest, but have to be requested at runtime.

Categories