How to check whether NFC is enabled or not in android?

后端 未结 5 1216
走了就别回头了
走了就别回头了 2020-12-25 12:09

How can i check whether NFC is enabled or not programmatically? Is there any way to enable the NFC on the device from my program? Please help me

5条回答
  •  再見小時候
    2020-12-25 13:01

    I might be a little late here, but I've implemented a 'complete' example with detection of

    1. NFC capability (hardware), and
    2. Initial NFC state (enabled or disabled in settings), and
    3. Changes to the state

    I've also added a corresponding Beam example which uses the

    nfcAdapter.isNdefPushEnabled()
    

    method introduced in later Android versions to detect beam state like in 2) and 3).

提交回复
热议问题