Search code examples
androidnfcandroid-permissions

Can I get access to NFC without manifest permission in android?


I need to create app with optional NFC functionality. Can I get access to NFC without manifest permission (Android)? Or should I create two apps: an NFC version and one without it.


Solution

  • Updated as per finding of thorbear

    The uses-feature element so that your application shows up in Google Play only for devices that have NFC hardware:

    <uses-feature android:name="android.hardware.nfc" android:required="true" />
    

    If your application uses NFC functionality, but that functionality is not crucial to your application, you can omit the uses-feature element and check for NFC avalailbility at runtime by checking to see if getDefaultAdapter() is null.


    This is not possible without adding permission into manifest. And you do not required to create two apps for such case.

    Read Requesting NFC Access in the Android Manifest for more details

    But yes you have a way to say "My application uses NFC feature but optional". For this you need to add <uses-feature android:name="android.hardware.nfc" android:required="false" /> into manifest. So Google play can make your application available for all devices which have NFC or not have.

    Note : If you do not add this <uses-feature .../> tag into manifest with android:required="false", Google Play will treat your application as "this application is only for devices which having NFC". And a device which does not have NFC feature, can not download your application from Google Play.


    Here is manifest example

    <manifest ...>
        <uses-feature android:name="android.hardware.nfc" android:required="true" />
        <uses-permission android:name="android.permission.NFC" />
    
    </manifest>
    

    Read more about <uses-feature>