Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [Tier2] trying to build a NFC class

Author
Message
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 26th Jan 2017 14:18 Edited at: 26th Jan 2017 20:04
Guys, I need your help.

I am trying to bring NFC functionality to my NDK project.
So far I have managed to recieve integers using jni based on a function in AGKHelper.java
(I used the GetOrientation function as a template)

Now it seems like I have to create a listener for the nfc device and a nfc class in AGKHelper.java
but I don't know how to start.

My Target is to get the "NFC Tag ID" as integer into my NDK project.
I am quite desperate at this point. It is hard to good tutorials for this problem.

This is what I got so far:

It`s a working code to get Integers from Java functions to NDK

I have added this in the Core.cpp to get an Integer from a Helper Class function:
This after the includes:

And this after the getorientation call (there are two places in the code):


In the template.h file I added:


So I can use it in the template.cpp like that:



And this to the AGKHelper.java, after the getorientation command:


So It works, I can get the right integers in the template.cpp from AppGameKit ( still havn't figured out how to pass strings. )
Now I have no Idea how to fill the java functions returns with correct nfc information.

Any help?

[/url]
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 27th Jan 2017 14:53 Edited at: 27th Jan 2017 15:44
This is my Class Template inside the AGKHelper.java
and this should be combined with the Android NFC api "Foreground Dispatch System"
https://developer.android.com/guide/topics/connectivity/nfc/index.html

But I also think, that it should be possible to approach the NFC data by using the Android NfcAdapter class

https://developer.android.com/reference/android/nfc/NfcAdapter.html
Anyone knows how?





Right now I do not even have a clue how to initialize the nfc Foreground Dispatch System

[/url]
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 27th Jan 2017 16:33
I have a project on the back burner that requires NFC communication so will be following this thread!

Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 27th Jan 2017 16:53
Thanks CJB,
please add everything you know about JNI/ Java into this Thread

[/url]
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 29th Jan 2017 11:48 Edited at: 29th Jan 2017 11:49
I have still trouble to get strings from a java method inside AGKHelper,
I try to use this template to aquire the Model name, but it does not work with a method from AGKHelper. :S

The code is added in Core.cpp after the int getModel( ANativeActivity* pActivity, char *szOut ) function


Are there any ideas about this one ?

[/url]
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 29th Jan 2017 15:29 Edited at: 29th Jan 2017 15:42
I got the intent working, but it was not my target.
I need the "Foreground Dispatch" to recieve nfc data while the app is running - but it's still a nice litte feature. With a little work, you can also specify the intent on special Tag information, so the app will only start, when a special card is scanned.

Currently it's like that:
Scan NFC Tag => App will start => TagID send to NDK


in the "override on start" part of AGKActivity.java:



in the manifest.xml

You need to give your app permission for NFC first:




(in the activity android:name..... AppGameKit Activity - section:



this does also require a static integer defined in the Helper Class inside AGKHelper


Combined with the NDK integer call function posted above, this can start your app by moving your device over a nfc tag, and the TagID can be recieved as integer in AGK.

Ahg this would be a very nice idea for a Tier1 plugin, but right now we have no infrastructure to archieve this.

[/url]

Login to post a reply

Server time is: 2024-11-24 20:59:05
Your offset time is: 2024-11-24 20:59:05