NFC Android
-
I have been for a week trying to use the NFC in android.
3 years ago i implemented a tag transmitter for a mime tag using JNI, with the same mobiles i am using now.
I dont wanna reuse that old code, as i modified the android.java, and i dont wanna reinvent the wheel for each platform Qt "gives" support for NFC
Why there is a QNearFieldShareManager? Why not just QNearFieldManager
When signal for a QNearFieldTarget detected is received, i run this:```qDebug() << "Target detected to read messages "<<target <<" "<<m_target->hasNdefMessage(); connect(target,&QNearFieldTarget::ndefMessageRead,this,&NFCReader::readMessage, Qt::UniqueConnection); connect(target,&QNearFieldTarget::requestCompleted,this,&NFCHelper::processRequestCompleted, Qt::UniqueConnection); connect(target,&QNearFieldTarget::error,this,&NFCHelper::error, Qt::UniqueConnection); QNearFieldTarget::RequestId id = target->readNdefMessages(); qDebug() << "VALID "<<id.isValid();```
VALID returns true, but i get signal error, with error : QNearFieldTarget::Error(TargetOutOfRangeError)
between "Target detected to read messages NearFieldTarget(0x5d35d620) true" and the VALID trace i get:
W/System.err(27837): java.lang.NullPointerException W/System.err(27837): at android.nfc.tech.BasicTagTechnology.connect(BasicTagTechnology.java:73) W/System.err(27837): at android.nfc.tech.Ndef.connect(Ndef.java:76) W/System.err(27837): at dalvik.system.NativeStart.run(Native Method)
The device sending the message, dont show any trace..? no QNearFieldTarget detected , so who is sending it, and what?
If application is closed, when i receive the message it opens, as it is registered in the AndroidManifestI tryed using QNearFieldShareManager and QNearFieldManager directly
-
@bnogal Did you check https://doc.qt.io/qt-5/nfc-android.html ?
-
@jsulm Thx for a reply in this desperating thing...
I checked that page already (a bit hidden by the way). It is registered and the application get launched on tag detection, but i don't receive the data because the QNearFieldTarget::Error(TargetOutOfRangeError) probability related to the null pointer exception in java.i wonder if it could be related to https://bugreports.qt.io/browse/QTBUG-59343