Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-64415

Android Qt NFC manager may not start

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.10.1, 5.11.0 Beta 2
    • 5.9.2, 5.10.1, 5.11.0 Beta 2
    • Connectivity: NFC
    • None
    • Cross-compile Win10/Android

      Tested on Android NDKr10e, NDKr11c, NDKr15c

      Android SDK: 24.2.5

      Qt : 5.9.2

      JDK 1.8.0_20

      Ant 1.9.7

      Tested on Android 5.1.1, 6 & 7

    Description

      If the QNearFieldManager is created too early (during the app startup & before the app.exec()), a NFC card Id is not read.

      To solve that problem, add a delay which gives a chance to the QMainLoop to start & then create the QNearFieldManager. There is no need to add a delay between the QNearFieldManager creation & the startTargetDetection call.

       

      NfcClient::NfcClient(QObject *parent): QObject(parent)
      
      { 
      
            // Does not work     
      
           // manager = new QNearFieldManager(this);
      
       
      
            // Works
      
            QTimer::singleShot(100, this, SLOT(onInitNfc()));
      
      }
      
       
      
      void NfcClient::onInitNfc(void)
      
      {  
      
            manager = new QNearFieldManager(this);
      
            manager->startTargetDetection();
      
            ...
      
      }
      
       
      
      int main(int argc, char *argv[])
      
      {
      
            QApplication a(argc, argv);
      
            NfcClient nfcclient; 
      
            return a.exec();
      
       }

       Manifest file :

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

       

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              adoherty Andrew O'Doherty
              draimond David RAIMOND
              Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes