0

I'd like to make a simple notes app, which should work on very basic versions of Android. However, I'd also like to add a feature which, for example, scans data from NFC and adds them to the notes.

The issue here is that NFC requires minimum API Level 10. I don't want to put android:minSdkVersion="10" over such a small feature.

Is there a way to have the code disable the "use NFC" button/code if they're using a phone below API level 10?

t0mm13b
  • 34,087
  • 8
  • 78
  • 110
Muz
  • 5,866
  • 3
  • 47
  • 65
  • You can check the API version using the answer linked below. http://stackoverflow.com/questions/3423754/retrieving-android-api-version-programmatically – Aviral Jul 18 '12 at 06:10

2 Answers2

1

From this answer you can check if the NFC is available and turned on. If it is, turn on the feature for your app, otherwise disable it. That way you can target API 10 but have the min set lower.

Community
  • 1
  • 1
Ashterothi
  • 3,282
  • 1
  • 21
  • 35
  • Thanks, but I was hoping for an easy "if API is 10, then.." type of command if possible. I can't think of any other specific example. – Muz Jul 18 '12 at 06:00
  • I would note that not all API 10 devices have NFC, you should not offer functionality that the device does not provide. I would still check to see if the NFC is available. – Ashterothi Jul 18 '12 at 14:13
1

Into the Android developers guide you can see an example (in this case centered on UI components): http://developer.android.com/training/backward-compatible-ui/using-component.html