What's the difference between enableReaderMode and enableForegroundDispatch?

前端 未结 2 1889
挽巷
挽巷 2020-12-29 08:22

I found two approaches to let an Android app detect and process NFC tags:

  1. NfcAdapter.enableReaderMode(activity, callback, flags, extras) and th

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-29 09:08

    enableReaderMode: Limit the NFC controller to reader mode while this Activity is in the foreground.

    enableForegroundDispatch: This will give priority to the foreground activity when dispatching a discovered Tag to an application.

    So basically you can use both for the same purpose, which is reading/writing a tag. enableReaderMode is used by Android phones in combination with a Broadcom NFC controller, because there is a bug on the presence check. As far as I know, only the enableReaderMode can dodge this by increasing EXTRA_READER_PRESENCE_CHECK_DELAY.

提交回复
热议问题