-
Notifications
You must be signed in to change notification settings - Fork 574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wait for channelCallback #444
Open
paolosanchi
wants to merge
11
commits into
chariotsolutions:master
Choose a base branch
from
paolosanchi:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…hen the channel is ready
I've added another commit to avoid the infinite loop, that's a waste of cpu, so I've added a list of sleeping thread that has to be awaken then the channel is ready |
…fc.stopHandover from README and phonegap-nfc.js
This reverts commit a7fa359.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: