On Thu, Aug 11, 2011 at 4:08 AM, Dominik <[email protected]> wrote: > I would like to use NFC if this feature is available on my device, and > if not, I will use some other technology. > The API level we are working on is API level 7, and the question is, > how the NFC functionality is > accessed if it is available? > > With method > getPackageManager().hasSystemFeature("android.hardware.nfc") > I can check whether NFC is supported, but what is the pattern to > access this functionality then?
Use conditional class loading. Put all your NFC-specific code in a class that you refer to *if and only if* you are on a suitable device. Having the code referring to a newer API Level is fine, so long as you never try running it on an older device. For example, in this sample project, I use a HoneycombHelper class to isolate getActionView(), to allow me to add custom widgets to the action bar on Honeycomb but still work on older devices: https://github.com/commonsguy/cw-android/tree/master/Menus/ActionBarBC -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 3.6 Available! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

