I need to force enable the NFC option over an Android device.
Is there a code which does the following without asking the user about it?
I need to force enable the NFC option over an Android device.
Is there a code which does the following without asking the user about it?
You can't just change the settings of the phone without the users awareness. Closest you can do is send the user to the relevant setting with an intent depending on the api level:
Settings.ACTION_NFC_SETTINGS for api level 16 and above,
For below API 16 use Settings.ACTION_WIRELESS_SETTINGS.
Make a change to the android manifest file and add the following things:
<uses-feature android:name="android.hardware.nfc" android:required="false" />
<uses-permission android:name="android.permission.NFC" />
It will ask the user whether he/she wants to allow the app to access NFC but it won't repeatedly ask them, as for accessing it without any permissions - that is not only unethical but it's impossible. It was already covered in the following thread: Can I get access to NFC without manifest permission in android?