NFC on Android



  • Does the nfc plugin for android works?
    I've tried by using the c++ and the qml but nothing worked.



  • I found this:

    Note: On Android, Qt Nfc only works in foreground applications. Android services are not supported which is due to API limitations on the Android side.

    Does this mean that i can not write a program in qt to read nfc tags from android?


  • Lifetime Qt Champion

    Hi,

    No, it means that your application must be the current active one in order to get something from the NFC reader.



  • I run the examples into my android device (samsung galaxy s2 plus) but it returns that "NFC not available". Why is that?



  • An example of my code is:

    m_manager = new QNearFieldManager(this);
    if (!m_manager->isAvailable()) {
    qWarning() << "NFC not available";
    return;
    }

    QNdefFilter filter;
    filter.setOrderMatch(false);
    connect(m_manager, SIGNAL(targetDetected(QNearFieldTarget*)),
            this, SLOT(targetDetected(QNearFieldTarget*)));
    connect(m_manager, SIGNAL(targetLost(QNearFieldTarget*)),
            this, SLOT(targetLost(QNearFieldTarget*)));
    

    I also write this into manifest in order to be the current one:

    <intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:mimeType="text/plain"/>
    </intent-filter>


  • Lifetime Qt Champion

    Did you try to run one of Qt's NFC examples ?



  • What example i can use to run it in Android?
    The only one is to read, that is QML CorkBoard example, and it can only read android:mimeType="text/plain"

    And i think the example to write records, NFCeditor, can only generate text records not encoded as mime.

    So if i modify that examples to make them "run", i will end up having the same as in my application that is not working.

    In the other hand, i found out a problem in my code, mime must be lowercase. If this can help somebody



  • I write because my thread with same topic...
    https://forum.qt.io/topic/80451/nfc-android


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.