Try to read a NFC tag with my Android phone

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Peter@multidesk.se
Posts: 136
Joined: Fri Oct 14, 2011 6:53 am

Try to read a NFC tag with my Android phone

Post by Peter@multidesk.se » Wed Oct 11, 2017 10:14 am

I don't get "nfcTagReceived" to work?
My phone beeps but the message does not seem to be trapped by livecode.

Does anyone else experienced this problem?

///Peter
/*Whats all the fuss with c# ?*/

Peter@multidesk.se
Posts: 136
Joined: Fri Oct 14, 2011 6:53 am

Re: Try to read a NFC tag with my Android phone

Post by Peter@multidesk.se » Wed Oct 11, 2017 11:58 am

Ok, now I am confused...

After some testing I found out that "mobileEnableNFCDispatch" doesn't work as well...

This whole NFC thing dosen't seem to work at all... Is there anyone that has got this to actually work?


///Peter
/*Whats all the fuss with c# ?*/

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Try to read a NFC tag with my Android phone

Post by Mikey » Wed Oct 11, 2017 2:02 pm

have you emailed jacque, yet? She paid to have the external written.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Try to read a NFC tag with my Android phone

Post by jacque » Wed Oct 11, 2017 5:55 pm

No need to email, I'm here. :) I've been using NFC in a commercial project and it works very well. The sample scripts in the dictionary are correct and are the basis of my scripts.

You must enable NFC before use and disable it when the stack closes. I assume you're doing that.

Not all Android devices support NFC so make sure yours does. Every manufacturer puts the reader in a different place so you need to know exactly where to tap for your device. On my Android tablet the hot spot is in the center of the back panel. On my Samsung phones it's about a 2/3 of the way down. On my pixel it's somewhere in between. Android will beep when it senses a signal. There are two different beep sounds, one for a successful read and another for an unsuccessful one. If the read fails, the app won't get any notifications.

Download NFC Tools from Android Play and practice with that to see how your phone behaves.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Peter@multidesk.se
Posts: 136
Joined: Fri Oct 14, 2011 6:53 am

Re: Try to read a NFC tag with my Android phone

Post by Peter@multidesk.se » Wed Oct 11, 2017 6:43 pm

Jacque,

I've done all that and the phone works with an NFC app from Google play.

this is what I tried:


on preOpenCard
    if the environment is "mobile"
    then
       if mobileIsNFCAvailable () is "true" then answer "NFC tags can be read" ## This works fine
     
       if mobileIsNFCEnabled () is "true" then answer "Device NFC has been turned on" ## This works fine
      
       if mobileIsNFCEnabled () is "false" then answer "Device NFC has been turned off" ## This works fine
    end if
end preOpenCard



on openCard
    if the environment is "mobile"
    then
       mobileEnableNFCDispatch ## does not seem to work because the NFC app from google play opens ...
    end if
end openCard

on closeCard
    if the environment is "mobile"
    then
       mobileDisableNFCDispatch
    end if
end closeCard

on nfcTagReceived ncfTag
    answer "Reading Ok!" ## Nothing happens, not executed.
end nfcTagReceived



///Peter
/*Whats all the fuss with c# ?*/

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Try to read a NFC tag with my Android phone

Post by jacque » Wed Oct 11, 2017 8:13 pm

Oh, I know what's wrong. You need to include the NFC extension in the standalone settings. When I first started using it, there was no such thing in the extensions list so I had to add it manually. I just checked the list in LC 9.x and I see they still haven't added it, so there would be no way you'd know about it.

In the message box, do this:

Code: Select all

set the cRevStandaloneSettings["android,nfc"] of stack "myStack" to true
Then do a new build. I'll submit a bug report, that extension really needs to be available and visible.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Try to read a NFC tag with my Android phone

Post by jacque » Wed Oct 11, 2017 8:22 pm

Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Android Deployment”