EddyVerbruggen / nativescript-nfc

:pencil: NativeScript plugin to discover, read, and write NFC tags
MIT License
84 stars 37 forks source link

IllegalStateException when pausing app after new Nfc() #45

Closed sylann closed 4 years ago

sylann commented 5 years ago

On android, in the Nfc constructor, you are delaying the initialisation of the adapter with a setTimeout of 3 seconds. This is causing an IllegalStateException if you pause the app between these 3 seconds.

I can't seem to find a way to catch this error, any idea?

-- By the way, I get this because I try to ask the user to enable NFC in the settings (and it would be a good idea to explain this part in your doc if you have a little time).

-- EDIT: Right now, to avoid the bug, I have removed the setTimeout from your code and I always instantiate the nfc handler inside of a page, only if needed.