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:
int deviceNFCexist = 0;
int deviceNFCtag;
int GetNFCDeviceexist()
{
return deviceNFCexist;
}
int GetNFCDeviceTag()
{
return deviceNFCtag;
}
And this after the getorientation call (there are two places in the code):
// nfc from java helper class
jmethodID methodGetNFCDevice = lJNIEnv->GetStaticMethodID( classHelper, "GetNFCDeviceexist","(Landroid/app/Activity;)I");
if ( !methodGetNFCDevice ) agk::Warning("Failed to get method GetNFCDeviceexist");
// get nfc device exist number from JDK to NDK
deviceNFCexist = lJNIEnv->CallStaticIntMethod( classHelper, methodGetNFCDevice, lNativeActivity );
jmethodID methodGetNFCTag = lJNIEnv->GetStaticMethodID( classHelper, "GetNFCDevicetag","(Landroid/app/Activity;)I");
if ( !methodGetNFCTag ) agk::Warning("Failed to get method GetNFCDevicetag");
// get nfc device exist number from JDK to NDK
deviceNFCtag = lJNIEnv->CallStaticIntMethod( classHelper, methodGetNFCTag, lNativeActivity );
In the
template.h file I added:
extern int GetNFCDeviceexist();
extern int GetNFCDeviceTag();
So I can use it in the template.cpp like that:
agk::Print(GetNFCDeviceexist());
agk::Print(GetNFCDeviceTag());
And this to the
AGKHelper.java, after the getorientation command:
public static int GetNFCDeviceexist( Activity act )
{
int outnum = 1234321;
return outnum;
}
public static int GetNFCDevicetag( Activity act )
{
int outnum = 222;
return outnum;
}
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?