Is it possible to declare a uses-permission for an app such that the permission is only given if the sdk version is at least a certain value?
I ask because I recently updated to KitKat (SDK Version 19) and to query for album art, one must now have the READ_EXTERNAL_STORAGE permission. But I don't want those updating the app to require a new permission just because those in 4.4 now require it...
Thanks
Just don't target KitKat, see http://developer.android.com/guide/topics/security/permissions.html
"Over time, new restrictions may be added to the platform such that, in order to use certain APIs, your app must request a permission that it previously did not need. Because existing apps assume access to those APIs is freely available, Android may apply the new permission request to the app's manifest to avoid breaking the app on the new platform version. Android makes the decision as to whether an app might need the permission based on the value provided for the targetSdkVersion attribute. If the value is lower than the version in which the permission was added, then Android adds the permission."
Related
Runtime permissions are essential to ensure that your apps get the required permissions to function, on android 6+ devices, however, it seems like some top developers (gameloft, ea games) do not find the need to implement runtime permissions, and they are rather happy on target SDK 22. So my questions are:
Why do I need take the pain of adding run-time permissions, when I can be stay on api 22. This would also save some lines of code.
Is it possible to upgrade from target SDK 22 to target SDK 23 once the app has been published? If I plan to stay on SDK 22 for now. It seems like downgrading is not possible. " Keep in mind that once you publish an APK targeting API level 23 or higher, you won't be able to submit an update targeting API level 22 or lower on any channel. "
Why do I need take the pain of adding run-time permissions, when I can be stay on api 22
Your "I can be stay on api 22" assumption may not hold up well over time. For example, the user will be told that your app is not compatible with multi-window.
Also, users see that the app is not supporting runtime permissions right away at install time, as they are prompted with the classic install-time permission dialog. Users, over time, will start to think that apps that show that dialog are out of date and not being maintained, and so they may not bother installing your app.
Also, certain third-party libraries that you may want to use may insist upon a higher targetSdkVersion.
So, while technically you can have any targetSdkVersion you want, there are costs.
This would also save some lines of code.
Not necessarily. The user can still revoke these permissions from within Settings, and so you may need more error-handling code than before.
Is it possible to upgrade from target SDK 22 to target SDK 23 once the app has been published?
In general, yes.
I know that if you set target sdk to 23 you now need to ask the users for "dangerous" permissions at runtime like was responded here:
Android 6.0 Permission Error
But some permissions are listed as "normal" and they are required when the app is installed. Is it possible to somehow mark some of the "dangerous" requirements that we have in our manifest to act as "normal" (to require them on install and not at runtime) because without some of them the app cannot actually function properly. Just rewriting everything to ask permissions at runtime is not really an option at the moment, but we will probably do that in the future.
No. There is no way to do what u want.
If you don't have the time to develop it now, you should target SDK 19 (permissions were introduced on Lollipop 21)
edit:
my bad, you should target API 22, as permissions were introduced on API 23. But still, target a lower API is the best option until you have time to properly develop the permission model.
Is it possible to somehow mark some of the "dangerous" requirements that we have in our manifest to act as "normal" ?
No it is not possibile.
The only way to avoid managing the runtime permissions is to use target 22.
But pay attention.
The users can revoke permissions from any app at any time, even if the app targets a lower API level
According to Android M Changes page, there is a new platform changes for Android 6.0. and they saying that
If you have previously published an app for Android, be aware that these changes in the platform affect your app.
So if my app is previously released before Android M release, and my app targeting API 21
1- Does this new changes will affect it?
2-Does i have to update my code to follow this new changes to be compatible with Android Mand raise the API Level to be 23?
** take in consideration in Android developer they says
If the API level of the platform is higher than the version declared by your app's targetSdkVersion, the system may enable compatibility behaviors to ensure that your app continues to work the way you expect.
Does this forward compatibility is applied to the Android M changes or not?
** i know this is a foolish version and i am daft man but please i need a help.
Does this new changes will affect it?
Some will. For example, while all of your permissions that you request in the manifest will be granted at install time (as they used to), the user can go in and deny them to your app in Settings. However, usually, all this will do is block access to data from your app, in ways that you should be handling already. For example, you might ask for READ_CONTACTS and query ContactsContract, but you should be handling the case where the user has no contacts. On Android 6.0, you might get no contacts in response to your query because the user denied your app access to contacts.
Does i have to update my code to follow this new changes to be compatible with Android Mand raise the API Level to be 23?
Generally speaking, no. Older Android apps usually work fine on Android 6.0.
However, eventually, there will be something that you want to have that requires targetSdkVersion of 23 or higher, in which case you will need to take other changes into account, such as the runtime permissions. And, you will need to test your app on Android 6.0, to see if Android 6.0's changes trigger bugs in your code.
I'm wanting to clarify on the key changes of marsh mallow 6.0.
Are there any changes that we need to be aware of as developers, as opposed to user only or OS features that do not affect development.
If so how do we manage these changes? example do we need to disable a feature, will it cause application crashes or it will open the setting page and asking for enabling the feature for that application.
I was so confused about how the recent changes affect developers, I was looking for some clarity.
As far as I can see there's no need to enable or disable features, the developer needs to be mindful of what target sdk they are developing in when creating or updating apps.
The biggest change to developers in the latest upgrade is Runtime Permissions.
Taken from:
Everything every Android Developer must know about new Android's Runtime Permission
Although Android is being keep developed but the latest update to Android M is totally different since there is some major change that would change everything like new Runtime Permission. Surprisingly it is not much talked about in Android Developer community even though it is extremely important and may cause some big trouble in the near future.
.../...
You might already feel like there is some cold wind blowing through your arms ... If you are an Android Developer, you will suddenly know that programming logic is totally changed. You cannot just call a function to do the job like previous but you have to check for the permission for every single feature or your application will just simply crash !
Correct. I would not spoil you that it is easy. Although it is a great thing for user but it is truly nightmare for us developer. We have to take coding to the next level or it will surely have a problem in both short-term and long-term.
Anyway this new Runtime Permission will work like described only when we set the application's targetSdkVersion to 23 which mean it is declared that application has already been tested on API Level 23. And this feature will work only on Android 6.0 Marshmallow. The same app will run with same old behavior on pre-Marshmallow device.
This means user permissions are not being requested at install time, but at runtime. This is done using a permission request, and can be saved by the user for one run of the app, or as a default 'always'. This permission can always be revoked in the device settings.
As the api is backward compatible, any devices running with apps of targer sdk < 23 will still be ok.
However these same apps will not run on android devices >= 6.0 with a target sdk of 23 if the runtime permissions are not implemented and the user failing to give permission needs to be managed to stop apps from crashing.
The only manisfest permissions that will require runtime permission requests are those that are deemed as a dangerous permission level, so accessing personal information, camera, etc.
Permissions are grouped and once a permission is given for one item of a group, permission is then granted for the remaining permissions of the group.
For more detail Sytem - Permissions.
I have an old app which I have to make small changes to, create a new version and update it to Google Play. Do I need to implement the new asking permissions on runtime type? Or can I just update the new version and it will work fine on Marshmallow?
The new Runtime Permission will work only when we set the application's targetSdkVersion to 23. And this feature will work only on Android 6.0 Marshmallow and above. The same app will run with same old behavior on pre-Marshmallow device.
If the device have Marshmallow or above, but your app's TargetSdkVersion < 23, Your app will continue to use the old permissions model, but the user can revoke permissions any time.
Any way if your app declares in its manifest that it needs a normal permission, the system automatically grants the app that permission at install time.
It should still work fine if you use targetSdkVersion 22 or less. If you set targetSdkVersion 23, then your app will crash if you attempt to use a "Dangerous permission" that you did not ask the user for at runtime. Take a look at this page:
https://developer.android.com/training/permissions/requesting.html
yes, it will work on marshmallow.
just include the "target api" to '23' in your manifest file.