No prompt or toggle for Android permission - android

In my app on Android 7, targetSdkVersion 24, I am trying to request an Android permission WRITE_EXTERNAL_STORAGE. However, when I run the app, it never prompts me for this permission, and when on my device I go to Settings > Apps > MyApp > Permissions, I do not see a toggle for anything related to WRITE_EXTERNAL_STORAGE.
Have I missed a step somewhere?
AndroidManifest.xml (complete file on pastebin)
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
MyActivity.java
int permission = activity.checkSelfPermission(perm);
if (permission != PackageManager.PERMISSION_GRANTED)
activity.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);

After spending some time to investigate, I have developed a theory on this issue.
My app has some dependencies that has this in their AndroidManifest.xml:
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
What this does is auto deny WRITE_EXTERNAL_STORAGE permission if the SDK is higher than 18. That's consistent with the issues I am getting; Permission getting denied and not even prompt the user.
Then I test adding this to my App AndroidManifest.xml in attempt to override the lib dependency permission settings:
android:maxSdkVersion="25"
It then fails to build due to Merge conflict on masSdkVersion. This further confirms my suspicions on the issue; the android:maxSdkVersion propagated to the App module.
After digging through the docs, I can't find the solution, but I have a work around. READ_EXTERNAL_STORAGE is in the same group as the WRITE_EXTERNAL_STORAGE, and the doc says asking a permission for the same group would apply to the rest of permission for the whole group.
So I tested asking READ permission throughout my App and AndroidManifest.xml, it works, but I think it's stupid.
I will update when I find a proper way to resolved.

Related

Remove WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions from Android Project

I removed the WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions from the project's AndroidMainfest.xml and AssemblyInfo.cs files.
I uploaded the .apk to Play Store and in the Bundle permissions the Write & Read permissions were showing up.
Then I analyzed the .apk using Analyze APK feature in Android Studio, and in that, AndroidMainfest.xml has WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE.
Though, I ask for CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage) on run time, but when I removed it and Analyzed the APK, still it includes WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions in Manifest file.
I then add the android:requiredFeature="false" flag to Write & Read permissions like this:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:requiredFeature="false" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:requiredFeature="false" />
And when I Analyzed the APK again, Write & Read permissions are there with android:requiredFeature="false". But on Play Store, in the Bundle permissions they are there as before.
I don't know why these permissions are ending up there?
#Sergey Comment: They can be merged from the dependent library. You can check if any library you are using have those permissions in their Manifest file.
I looked into it and found this article How Libraries can silently add permissions to your Android App and the Fix. It Worked.
But I'm using camera, and I was storing these pictures in the Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData). Which requires WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions.
So, I replace the path with FileSystem.CacheDirectory and it worked (Intenral Storage doesn't requires Read and Write Permissions in Manifest file).

Android: java.net.SocketException: Permission denied

Some of my app users are seeing the "Permission denied" exception
Specially for the following device: Xiaomi MI MAX Android OS: 7.0
Other devices are able to access Internet.
I've added the required permissions before the application tag, like this,
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application>
...
</application>
Can anyone please help what is wrong here?
For Android 6.0 and above, there is a new way of requesting permission from the user, which is called runtime permission, which means permission is granted when the app is running, not when it is installed like earlier versions.
Check the official guide for complete explanation

Permission denied, AndroidManifest.xml does not work

m developing launcher for 2.3.3 via specified STB. And I wrote permissions like
...
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
...
in AndroidManifest.xml.
While debugging -uninstall/install-, sometimes meet "Permission denied" so i should uninstall/install again and again till got no errors with "Permission denied".
Does anyone get this strange bug? Of course, I did not edit AndroidManifest.xml at all.
If while debugging your Device is connected to a PC and
Enable copy files to/from your computer.
Then you will see this Permission denied message.
I have had recently this problem, when I upgraded the targetSdkVersion to 23. The "problem" was the new system of dynamic permissions in Android. See http://developer.android.com/training/permissions/requesting.html

How to fix HARDWARE_TEST permission error?

i'm developing an android app which uses some hardware parts like camera or Wi-Fi, and i'm using HARDWARE_TEST permission in the manifiest:
<uses-permission android:name="android.permission.HARDWARE_TEST">
I never have had any issue with that, but now suddenly when I eclipse and manifiest file, a new error is shown in this line:
"Permission is only granted to system apps"
The only way i've got to fix it is deleting this line.
Why is this error?? How can I fix it?
Thanks
Edited:
I have found the solution and answer my own question:
My problem was in android:targetSdkVersion value in manifiest which was 15 and proyect build target was checked API level 16 (Android 4.1.2)
<uses-sdk
android:minSdkVersion="2"
android:targetSdkVersion="15" />
So i have changed android:targetSdkVersion value to 16 and Proyect properties > Android > "Proyect Buid Target" checked 16 too.
There are several permission protection level for Android Permissions: Normal, Dangerous, System and signatureOrSystem.
signatureOrSystem Permission can only be granted to System applications. And For permissions in signature level:
A permission that the system grants only if the requesting application
is signed with the same certificate as the application that declared
the permission. If the certificates match, the system automatically
grants the permission without notifying the user or asking for the
user's explicit approval.
Here is the permission definition syntax.
Here is the definition of the HARDWARE_TEST permission:
<!-- Allows access to hardware peripherals. Intended only for hardware testing -->
<permission android:name="android.permission.HARDWARE_TEST"
android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
android:protectionLevel="signature"
android:label="#string/permlab_hardware_test"
android:description="#string/permdesc_hardware_test" />
It is a signature permission in Android 4.2, so it can only be granted to app with the same signature(signed by vendor). So your application cannot request that permission.
If you want to directly manipulate hardware, you may need a rooted device.

Exception in android manifest file permission

I got exception in android manifest file.
I have added following permissions:
1. uses-permission android:name="android.permission.CALL_PRIVILEGED" />
2. uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
I got
"Permission is only granted to system apps" error. How to fix it. Before it was working fine.
you can't fix it. As mentioned:
"Permission is only granted to system apps"
This mean, no ordinary app can use the permissions. At least, not without rooting the device.

Categories

Resources