(I'm just now in the process of trying to understand the API Levels and permissions myself, so I'm making this post a bit verbose with what I've learned, hopefully helping people coming after me.)
API Levels
I'm trying to wrap my head around the API Levels. I understand that with higher levels there will be more functions available (and probably some old removed also). System updates tend to raise the API Level. I've also understood that in the manifest one is supposed to define both the minimum API Level (meaning the oldest version of Android your app can support) and the target API (which, as far as I can tell, probably should be the latest available API Level). The target API Level also controls the look of the app, so if one uses an old target level, the app will look old from day one.
Picking a minimum API Level is a challenge in itself. Here all levels are listed:
https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
And their initial release dates and support status:
https://en.wikipedia.org/wiki/Android_version_history
And here are the distributions of them in current use:
https://developer.android.com/about/dashboards/index.html
Looking at the distribution, one can see that as of today, if one support all the way back to 4.4 (including), one would target 89% of all devices. Which also syncs nicely with 4.4 being the oldest one actually supported by Google (look at the Wikipedia link above).
This would mean that we'd use this in the manifest:
(because 19 = Android 4.4, and 25 = Android 7.1.1)
Permissions
Different API Levels handle permissions differently. Which means we need to do different things in the manifest, depending on what API Level we use for targetSdkVersion. For instance, if we target API Level 23 or higher, we need to use runtime permissions. If we use an old enough target we might get away with more because security was more lax way back.
So far so good, but...
Here's what I don't understand
How are we to actually know for sure what API Levels and permissions to add? An example: I saw this tutorial by Erel, on how to read NFC tags. In it he clearly states "This library requires Android version 2.3.3 or above (API level 10 or above).", which is great. Yet when I add that lib to a project and set my minSdkVersion to "9", I don't get a warning. And when I take a look at NFC using B4X Object Browser I can't find anything related to API Levels either.
This post is not a critique of B4A or Erel in any way. Nor is it specifically about the NFC library. This is about me not understanding how I'm supposed to think when making a project, from an API Level perspective.
I don't know if it's possible to do this, but I think it would be nice to be able to get a report on my B4A project and the API Levels my code hits. That could lead to reasoning like "if I redo this portion of code to remove function A and B and C, I could lower my minSdkVersion and gain another X% potential users". And if I enable a library that require a higher API Level than what I currently have in the project I could get a message about that.
Like I said, I'm just beginning to understand this world, so all help in clarifying and correcting me is appreciated. I'm suspect that many here understand things about this topic that I haven't grasped yet, and you find it quite easy. Please share.
API Levels
I'm trying to wrap my head around the API Levels. I understand that with higher levels there will be more functions available (and probably some old removed also). System updates tend to raise the API Level. I've also understood that in the manifest one is supposed to define both the minimum API Level (meaning the oldest version of Android your app can support) and the target API (which, as far as I can tell, probably should be the latest available API Level). The target API Level also controls the look of the app, so if one uses an old target level, the app will look old from day one.
Picking a minimum API Level is a challenge in itself. Here all levels are listed:
https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
And their initial release dates and support status:
https://en.wikipedia.org/wiki/Android_version_history
And here are the distributions of them in current use:
https://developer.android.com/about/dashboards/index.html
Looking at the distribution, one can see that as of today, if one support all the way back to 4.4 (including), one would target 89% of all devices. Which also syncs nicely with 4.4 being the oldest one actually supported by Google (look at the Wikipedia link above).
This would mean that we'd use this in the manifest:
B4X:
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="25"/>
Permissions
Different API Levels handle permissions differently. Which means we need to do different things in the manifest, depending on what API Level we use for targetSdkVersion. For instance, if we target API Level 23 or higher, we need to use runtime permissions. If we use an old enough target we might get away with more because security was more lax way back.
So far so good, but...
Here's what I don't understand
How are we to actually know for sure what API Levels and permissions to add? An example: I saw this tutorial by Erel, on how to read NFC tags. In it he clearly states "This library requires Android version 2.3.3 or above (API level 10 or above).", which is great. Yet when I add that lib to a project and set my minSdkVersion to "9", I don't get a warning. And when I take a look at NFC using B4X Object Browser I can't find anything related to API Levels either.
This post is not a critique of B4A or Erel in any way. Nor is it specifically about the NFC library. This is about me not understanding how I'm supposed to think when making a project, from an API Level perspective.
I don't know if it's possible to do this, but I think it would be nice to be able to get a report on my B4A project and the API Levels my code hits. That could lead to reasoning like "if I redo this portion of code to remove function A and B and C, I could lower my minSdkVersion and gain another X% potential users". And if I enable a library that require a higher API Level than what I currently have in the project I could get a message about that.
Like I said, I'm just beginning to understand this world, so all help in clarifying and correcting me is appreciated. I'm suspect that many here understand things about this topic that I haven't grasped yet, and you find it quite easy. Please share.