Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In android I want to launch my app by scanning the nfc tag, so I followed what's specified in the doc's section "Launching your Android Application when Scanning a Tag"
The issue is that if I scan the tag with the app turned off it crashes at launch time.
It seems that the method execute(), which sets channelCallback is called after sendEvent()
So channelCallback is null and there is nothing that catches the exception
phonegap-nfc/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java
Lines 730 to 745 in d325b86
the stack of sendEvent() is this one:
onNewIntent() -> parseMessage() -> cordova.getThreadPool().execute(()=>) -> fireNdefEvent() -> sendEvent()
So what I done is to wait until channelCallback got set.
Warning!
What I did is to add a potential infinite loop, which could potentially block the thread, but it seems that sendEvent() is executed on a thread took from the threadPool (cordova.getThreadPool().execute(()=>)) so it should be fine.
In the end, it does the job done.
Maybe the problem comes from my environment: