0

I need to enable NFC if it is OFF when launch my APP. I found this way but I need turn on when launch my app automatcly.

if (nfcAdapter == null) {
            // NFC is not available for device
            alertDialogNfc( "Sorry! This device do not support NFC" );
        } else if (!nfcAdapter.isEnabled()) {
            // NFC is available for device but not enabled
            alertDialogNfc( "Please, turn on the NFC" );
            startActivity(new Intent("android.settings.NFC_SETTINGS"));
}
Nick
  • 1
  • 1
  • 4
  • Check out [this link](http://ranjithdroid.blogspot.com/2015/11/turn-onoff-android-nfc-by.html) – Alex Timonin Jul 04 '20 at 04:24
  • Thank you Alex, but android.permission.WRITE_SECURE_SETTINGS is deprecated in the last versions of Android and the program doesn't work. Any other idea? – Nick Jul 05 '20 at 01:29
  • Does this answer your question? [Android: Changing NFC settings (on/off) programmatically](https://stackoverflow.com/questions/5945100/android-changing-nfc-settings-on-off-programmatically) – Robert Jul 06 '20 at 11:07
  • Thanks Robert, but all these is for old version of Android. Someone said that it is not possible to do that, onother said "It is worth pointing out that this solution requires the device to be rooted.". I dont know if it is right or not. I have a huawei phone and their wallet APP can do it without open the intent ACTION_NFC_SETTINGS. So I am figuring out to find a solution. – Nick Jul 07 '20 at 07:18

0 Answers0