diff options
author | Peter Rustler <peter.rustler@basyskom.com> | 2015-03-02 11:10:33 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-03-18 08:46:09 +0000 |
commit | 3bc0616eb9110959a36ed4746600e6069e4a9392 (patch) | |
tree | aa7fbe188bb30a32e5d064c633fdfd9bd18402e6 /src | |
parent | 62fb78e9f6fd93e26cbe9fdc1fb1fffbb3ff4ef3 (diff) |
Catch the exception for disableForegroundDispatch for Android
In Android Nfc disableForegroundDispatch must be called while
the activity is still in foreground.
We catch the thrown exception if we do call
disableForegroundDispatch while we are in background.
Change-Id: I396ee3fcb7c7ea835d7d5ed2cb31bf0a8cabb0a8
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/android/nfc/src/org/qtproject/qt5/android/nfc/QtNfc.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/android/nfc/src/org/qtproject/qt5/android/nfc/QtNfc.java b/src/android/nfc/src/org/qtproject/qt5/android/nfc/QtNfc.java index e2c14431..ec1b6fa9 100644 --- a/src/android/nfc/src/org/qtproject/qt5/android/nfc/QtNfc.java +++ b/src/android/nfc/src/org/qtproject/qt5/android/nfc/QtNfc.java @@ -115,7 +115,7 @@ public class QtNfc try { m_adapter.enableForegroundDispatch(m_activity, m_pendingIntent, filters, techList); } catch(IllegalStateException e) { - // On Android we must call enableForegroundDisplatch when the activity is in forground, only. + // On Android we must call enableForegroundDispatch when the activity is in foreground, only. Log.d(TAG, "enableForegroundDispatch failed: " + e.toString()); } } @@ -129,7 +129,12 @@ public class QtNfc m_activity.runOnUiThread(new Runnable() { public void run() { //Log.d(TAG, "Disabling NFC"); - m_adapter.disableForegroundDispatch(m_activity); + try { + m_adapter.disableForegroundDispatch(m_activity); + } catch(IllegalStateException e) { + // On Android we must call disableForegroundDispatch when the activity is in foreground, only. + Log.d(TAG, "disableForegroundDispatch failed: " + e.toString()); + } } }); return true; |