WRITE_EXTERNAL_STORAGE Permission - android

Based on google docs beginning with Android 4.4 (API level 19) Android apps doesn't need WRITE_EXTERNAL_STORAGE Permission to write to its own application-specific directories.
uses-permission
So I removed this permission for API 19:
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
But after publishing app, we find out some android devices(not all of them) with API > 18 have problem and app can't write to it's own application-specific directories.
I remove android:maxSdkVersion and published app again and problem solved.
How is that possible?
And what I should do to remove this permission and my app work in all devices?

check following link hope you will find your ans
Require permission only for older android versions: maxSdkVersion does not work?

Related

Is it required to check the runtime permission WRITE_EXTERNAL_STORAGE when downloading a file with the DownloadManager?

In my app I'm not checking the permission at runtime. My app targets the SDK 25 and I've added
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
in the manifest.
From my tests, the app doesn't crash, probably because DownloadManager is a system service and it's not my app directly to download the file.
Is my reasoning correct or should I add the runtime check to request the permission to the user? I wouldn't want the app to crash when deployed on some devices.
Thanks!

How to ask for permission in my android app within playstore before downloading my app(Like ES File Explorer File Manager)? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to add the permissions to access the files and location of user in my android app. Right now when the user open my app, it asks for permissions but if the user deny it my app doesn't work fine due to the downloaded images in his phone. It gives bad impact. Now i want to ask that how i can ask for permission in my app within playstore before downloading my app(Like ES File Explorer File Manager). If the user deny this he can't able to install my app.
From the source: https://developer.android.com/training/permissions/requesting.html
If the device is running Android 5.1 or lower, or your app's target SDK is 22 or lower: If you list a dangerous permission in your manifest, the user has to grant the permission when they install the app; if they do not grant the permission, the system does not install the app at all.
So, i think you can set your target SDK and target API below 22 for using old permission system.
You can do it by selecting API22 as target SDK
If the device is running Android 5.1 or lower, or your app's target SDK is 22 or lower: If you list a dangerous permission in your manifest, the user has to grant the permission when they install the app; if they do not grant the permission, the system does not install the app at all.
BUT ALSO
Note: Beginning with Android 6.0 (API level 23), users can revoke permissions from any app at any time, even if the app targets a lower API level. You should test your app to verify that it behaves properly when it's missing a needed permission, regardless of what API level your app targets.
You have to add some usage permissions in AndroidManifest.xml.
Something like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
//for file access
<uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
//for location access and updates
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" />
</manifest>
after adding these permissions you have to create a new release build and post to play store.
Note: these permissions are working fine for API level below 23 but for API 23 or higher you have to check run-time permissions(marshmallow and nougat), for more info about Requesting Permissions at Run Time please go through this link-https://developer.android.com/training/permissions/requesting.html

Android 6.0 (M) skip Settings.ACTION_MANAGE_WRITE_SETTINGS with admin

Is it possible to avoid runtime permission with admin permission?
I have to change something in Settings.System, but unfortunately on Android M, I have to ask user to allow me...
Permission of WRITE_SETTINGS has been revoked from user apps (as in not system apps) in api23. From looking into source code in android we can see the following protection levels for this permission:
<permission android:name="android.permission.WRITE_SETTINGS"
android:label="#string/permlab_writeSettings"
android:description="#string/permdesc_writeSettings"
android:protectionLevel="signature|preinstalled|appop|pre23" />
which means you can gain this permission by either:
1.Targetting sdk lower then 23 in your manifest
2. By having system signature, by having app preinstalled in system (/app or /priv-app) or by gaining permission through appop (not relevant).
So, as user app targeting sdk23 you cannot gain this permission. Target sdk 22 and lower for gaining this permission from manifest. it works fine.

Difference Between uses-permission-sdk-23 and uses-permission?

I just come to know newer tag in android manifest file called "uses-permission-sdk-23"
<uses-permission-sdk-23 android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.CAMERA" />
Can anybody please provide difference between this two?
Summary
<uses-permission> applies to all SDKs and <uses-permission-sdk-23> will apply the permission only to SDK 23+.
When should you use <uses-permission-sdk-23>?
For Android SDK 23 and above, you have the option to request the permission at runtime but the permissions will be in their default state upon installation and the user will not be prompted at installation. (Essentially this can be used to prompt the user to grant the permission on a need-to-use basis and you have the opportunity to provide an explanation of why it's needed.)
However, for SDK 22 and below, the user is prompted at installation for permissions. As some permissions can seem suspicious or dodgy to the user, you may not want to request these for SDK 22 and below as you can't provide an explaination of why you need them beforehand, hence the <uses-permission-sdk-23> tag.
Additionally: the documentation is unclear as to whether sdk-23 permissions also cause the app to be filtered in the Play Store, but if it was your intention to do this, the documentation recommends that you make use of <uses-feature> elements instead to declare hardware compatability.
Recommendation
Generally, it is considered best practice to use <uses-permission-sdk-23> if your app does not need to support SDK 22 and below, or if the permission you are requesting is not needed for SDK 22 or below as it is then clear that this permission is requested at runtime.
Otherwise, <uses-permission> should be used as this is backwards compatible and the behavior will be correct on any SDK version; 22 and below, permissions will be requested at installation. 23 and above, it's up to you to request at runtime.
You should request permissions at runtime wherever possible as it allows you to explain to your user why you need certain permissions rather than just prompting them with a list of permissions at install time when the user has likely not established trust in the app.
Notes
Both of these accept a maxSdkVersion attribute that can be used when a permission was required for older devices but is not required for newer devices. (For example, the WRITE_EXTERNAL_STORAGE example shown in the Android documentation.)
Reference: (Android Documentation)
if the app is running on a device with SDK version 23 or higher. If the device is running SDK version 22 or lower
when you update an app to include a new feature that requires an additional permission. If a user updates an app on a device that is running SDK version 22 or lower, the system prompts the user at install time to grant all new permissions that are declared in that update. If a new feature is minor enough, you may prefer to disable the feature altogether on those devices, so the user does not have to grant additional permissions to update the app. By using the uses-permission-sdk-23 element instead of uses-permission
you can request the permission only if the app is running on platforms that support the runtime permissions model, in which the user grants permissions to the app while it is running.
for More info refer this.uses - Permission sdk 23
By using the <uses-permission-sdk-23> element instead of <uses-permission>, you can request the permission only if the app is running on platforms that support the runtime permissions model, in which the user grants permissions to the app while it is running.
This has been introduced to support runtime permission feature of Marshmallow (API-23) onwards.
This simply specifies that an app wants a particular permission, but only if the app is running on a device with SDK version 23 or higher. If the device is running SDK version 22 or lower, the app does not have the specified permission.
This element is useful when you update an app to include a new feature that requires an additional permission. If a user updates an app on a device that is running SDK version 22 or lower, the system prompts the user at install time to grant all new permissions that are declared in that update.
You can reffer to the documentation.
user-permission-sdk-23 specifies that the app that wants a particular permission is running on SDK version 23 or higher.
It is used when you update your app to run SDK 23 elements and the users running a lower API which does not support the new elements.
Android manifest - user permissions
Specifies that an app wants a particular permission, but only if the app is running on a device with API level 23 or higher. If the device is running API level 22 or lower, the app does not have the specified permission.
see the documentation
uses permission
Use
<uses-permission-sdk23>
to apply permission for Marshmallow devices only.

Google Map V2 - EXTERNAL_STORAGE permissions are optional for Android 6.0 onwards?

I have WRITE_EXTERNAL_STORAGE permission on manifest used by Google Map V2 API to load map.
Now, we are building the app to target android SDK to Marshmallow (23). So all the DANGEROUS permissions are requested for user permission at runtime. All other permissions are fine, but not sure what we should do with WRITE_EXTERNAL_STORAGE permission. Even without requesting the user for WRITE_EXTERNAL_STORAGE the google map works fine.
On the map Google Map ApiDemo sample, the WRITE_EXTERNAL_STORAGE is declared on manifest , but comment says EXTERNAL_STORAGE permissions are optional for Android 6.0 onwards.
https://github.com/googlemaps/android-samples/blob/master/ApiDemos/app/src/main/AndroidManifest.xml
I don't find any official android document about this. Let me know if you know any information on EXTERNAL_STORAGE permission.
From the Docs:
If you're targeting version 8.3 or later of the Google Play services SDK, you no longer need the WRITE_EXTERNAL_STORAGE permission to use the Google Maps Android API.
If you're targeting earlier versions of the Google Play services SDK, you must request the android.permission.WRITE_EXTERNAL_STORAGE permission.
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Note: If your app is targeting API level 23 (Android 6.0), which requires the use of runtime permissions, you should target version 8.3 or later of the Google Play services SDK.

Categories

Resources