NfcAdapter.getDefaultAdapter returns null when an Android application is launched with the intent BOOT_COMPLETED

NFC-based Android application that starts after the download is complete (when the event BOOT_COMPLETEDreceived by BroadcastReceiver).

Problem

Several times NfcAdapter.getDefaultAdapter(this)retunrs null; it is random / inconsistent, for some load cycles it works fine and returns NfcAdapter, and for other load cycles this method returns null.

I suspect that when it returns null, the NFC service is not already running, or the NFC service is not fully running at the time of the BOOT_COMPLETEDBroadcasted event .

Question

Is there a way to make sure the NFC service is up and running before the event BOOT_COMPLETEDis broadcast?

Assuming the device is rooted, will it help if init.rcchanged? If so, what is customization if anyone has encountered such a problem?

+4
source share

Source: https://habr.com/ru/post/1526662/


All Articles