chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
706 stars 564 forks source link

Error on application exit #87

Closed asnp87 closed 11 years ago

asnp87 commented 11 years ago

Hi, i tried to implement the nfc plugin in my android application, all works fine but when i try to exit from the app i get a error message and in logcat i read: "Unable to destroy activity" and "you must disable foreground dispatching while your activity is still resumed". How an i resolve that? Thanks Alberto

JohnMcLear commented 11 years ago
06-06 20:26:17.659: E/AndroidRuntime(10268): java.lang.RuntimeException: Unable to destroy activity {co.mclear.nfcring/co.mclear.nfcring.nfc}: java.lang.IllegalStateException: You must disable foreground dispatching while your activity is still resumed
06-06 20:26:17.659: E/AndroidRuntime(10268):    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3112)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3130)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at android.app.ActivityThread.access$1200(ActivityThread.java:123)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1180)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at android.os.Looper.loop(Looper.java:137)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at android.app.ActivityThread.main(ActivityThread.java:4464)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at java.lang.reflect.Method.invokeNative(Native Method)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at java.lang.reflect.Method.invoke(Method.java:511)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:822)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:589)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at dalvik.system.NativeStart.main(Native Method)
06-06 20:26:17.659: E/AndroidRuntime(10268): Caused by: java.lang.IllegalStateException: You must disable foreground dispatching while your activity is still resumed
06-06 20:26:17.659: E/AndroidRuntime(10268):    at android.nfc.NfcAdapter.disableForegroundDispatchInternal(NfcAdapter.java:728)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at android.nfc.NfcAdapter.disableForegroundDispatch(NfcAdapter.java:714)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at com.chariotsolutions.nfc.plugin.NfcPlugin$3.run(NfcPlugin.java:273)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at android.app.Activity.runOnUiThread(Activity.java:4224)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at com.chariotsolutions.nfc.plugin.NfcPlugin.stopNfc(NfcPlugin.java:267)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at com.chariotsolutions.nfc.plugin.NfcPlugin.onPause(NfcPlugin.java:444)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at org.apache.cordova.api.PluginManager.onPause(PluginManager.java:294)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at org.apache.cordova.api.PluginManager.init(PluginManager.java:84)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at org.apache.cordova.CordovaWebView.loadUrlIntoView(CordovaWebView.java:410)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at org.apache.cordova.CordovaWebView.handleDestroy(CordovaWebView.java:807)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at org.apache.cordova.DroidGap.onDestroy(DroidGap.java:726)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at android.app.Activity.performDestroy(Activity.java:4683)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1079)
06-06 20:26:17.659: E/AndroidRuntime(10268):    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3099)
06-06 20:26:17.659: E/AndroidRuntime(10268):    ... 11 more
JohnMcLear commented 11 years ago

@don any update / thoughts on this?

don commented 11 years ago

I haven't had a chance to look into this. I need to look at the lifecycle, this used to be handled ok. Are you seeing any problems or just errors? I'm hoping to get some time for this and 2.8 updates next weekend.

JohnMcLear commented 11 years ago

The problem /error is that on Android when you end any app using this plugin that has the listener added the application exception errors and the users see this error.

Looking forward to next weekend, will keep my eyes pealed :)

don commented 11 years ago

I created a sample app with Cordova-2.8 and didn't see this error using these instructions https://github.com/chariotsolutions/phonegap-nfc/blob/master/doc/GettingStarted.md

@JohnMcLear let me know if you're still seeing this with Cordova-2.8

JohnMcLear commented 11 years ago

Will do.

JohnMcLear commented 11 years ago

Using cordova 2.8.14

Test output:

C:\Windows\system32>npm install -g cordova
C:\Windows\system32>npm install plugman -g
...
C:\Windows\system32>cordova -v
2.8.14
D:
D:\>plugman -v
plugman version 0.7.10
D:\>git clone git://github.com/chariotsolutions/phonegap-nfc.git
D:\cordova create foo com.example.foo Foo
D:\>plugman --platform android --project foo --plugin phonegap-nfc
Warning: cordova version not detected. installing anyway.
Installing plugin com.chariotsolutions.nfc.plugin...
Error: "D:\foo\cordova\plugins\com.chariotsolutions.nfc.plugin\src\com\chariotsolutions\nfc\plugin\NfcPlugin.java" not found!
    at Object.module.exports.resolveSrcPath (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\platforms\common.js:10:46)
    at Object.module.exports.copyFile (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\platforms\common.js:22:30)
    at module.exports.source-file.install (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\platforms\android.js:40:20)
    at Object.ActionStack.process (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\util\action-stack.js:41:25)
    at handleInstall (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:267:13)
    at runInstall (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:219:9)
    at C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:39:17
    at Object.fetchPlugin [as fetch] (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\fetch.js:67:23)
    at possiblyFetch (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:34:31)
    at Object.installPlugin [as install] (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:24:5)
Error: "D:\foo\cordova\plugins\com.chariotsolutions.nfc.plugin\src\com\chariotsolutions\nfc\plugin\NfcPlugin.java" not found!
    at Object.module.exports.resolveSrcPath (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\platforms\common.js:10:46)
    at Object.module.exports.copyFile (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\platforms\common.js:22:30)
    at module.exports.source-file.install (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\platforms\android.js:40:20)
    at Object.ActionStack.process (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\util\action-stack.js:41:25)
    at handleInstall (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:267:13)
    at runInstall (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:219:9)
    at C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:39:17
    at Object.fetchPlugin [as fetch] (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\fetch.js:67:23)
    at possiblyFetch (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:34:31)
    at Object.installPlugin [as install] (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:24:5)

D:\foo>plugman --platform android --project foo --plugin phonegap-nfc
Warning: cordova version not detected. installing anyway.
Installing plugin com.chariotsolutions.nfc.plugin...
Error: "D:\foo\cordova\plugins\com.chariotsolutions.nfc.plugin\src\com\chariotsolutions\nfc\plugin\NfcPlugin.java" not fou
    at Object.module.exports.resolveSrcPath (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\platforms\common.j
    at Object.module.exports.copyFile (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\platforms\common.js:22:3
    at module.exports.source-file.install (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\platforms\android.js
    at Object.ActionStack.process (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\util\action-stack.js:41:25)
    at handleInstall (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:267:13)
    at runInstall (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:219:9)
    at C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:39:17
    at Object.fetchPlugin [as fetch] (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\fetch.js:67:23)
    at possiblyFetch (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:34:31)
    at Object.installPlugin [as install] (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:24:5)
Error: "D:\foo\cordova\plugins\com.chariotsolutions.nfc.plugin\src\com\chariotsolutions\nfc\plugin\NfcPlugin.java" not fou
    at Object.module.exports.resolveSrcPath (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\platforms\common.j
    at Object.module.exports.copyFile (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\platforms\common.js:22:3
    at module.exports.source-file.install (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\platforms\android.js
    at Object.ActionStack.process (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\util\action-stack.js:41:25)
    at handleInstall (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:267:13)
    at runInstall (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:219:9)
    at C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:39:17
    at Object.fetchPlugin [as fetch] (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\fetch.js:67:23)
    at possiblyFetch (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:34:31)
    at Object.installPlugin [as install] (C:\Users\john\AppData\Roaming\npm\node_modules\plugman\src\install.js:24:5)

D:\>
don commented 11 years ago

@JohnMcLear in the example above, you're mixing cordova-cli and plugman.

If you use cordova-cli to create the project, use "cordova plugin add ..\phonegap-nfc"

If you used the zip version of cordova to create the project, then it would be appropriate to use plugman to install the plugin.

See these documents for more details https://github.com/chariotsolutions/phonegap-nfc/blob/master/doc/GettingStarted.md https://github.com/chariotsolutions/phonegap-nfc/blob/master/doc/GettingStartedCLI.md

don commented 11 years ago

@albi87 can you try upgrading your command line tools and project to Cordova 2.8? You'll need to make sure the new jar file and cordova.js get into your project.

don commented 11 years ago

@JohnMcLear I think you need to upgrade to 2.8 also. You updated the command line tools, but the code is still 2.6.

You updated the version of the command line tools, but the generated project still contains the old cordova. https://github.com/mclear/my/tree/master/platforms/android/libs

Can you move assets/www/* to a new directory and re-generate the android project and install the latest phonegap-nfc? I did this to the example project that you were working on with devgeeks https://github.com/don/phonegap-nfc-test/tree/cordova-2.8

asnp87 commented 11 years ago

@don today i will try to update cordova!

asnp87 commented 11 years ago

i still have the problem: 06-12 12:55:52.456: E/AndroidRuntime(13393): FATAL EXCEPTION: main 06-12 12:55:52.456: E/AndroidRuntime(13393): java.lang.RuntimeException: Unable to destroy activity {com.dquid.DQuidIO/com.dquid.DQuidIO.DQuidIO}: java.lang.IllegalStateException: You must disable foreground dispatching while your activity is still resumed 06-12 12:55:52.456: E/AndroidRuntime(13393): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3778) 06-12 12:55:52.456: E/AndroidRuntime(13393): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3811) 06-12 12:55:52.456: E/AndroidRuntime(13393): at android.app.ActivityThread.access$1200(ActivityThread.java:151) 06-12 12:55:52.456: E/AndroidRuntime(13393): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1384) 06-12 12:55:52.456: E/AndroidRuntime(13393): at android.os.Handler.dispatchMessage(Handler.java:99) 06-12 12:55:52.456: E/AndroidRuntime(13393): at android.os.Looper.loop(Looper.java:155) 06-12 12:55:52.456: E/AndroidRuntime(13393): at android.app.ActivityThread.main(ActivityThread.java:5485) 06-12 12:55:52.456: E/AndroidRuntime(13393): at java.lang.reflect.Method.invokeNative(Native Method) 06-12 12:55:52.456: E/AndroidRuntime(13393): at java.lang.reflect.Method.invoke(Method.java:511) 06-12 12:55:52.456: E/AndroidRuntime(13393): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028) 06-12 12:55:52.456: E/AndroidRuntime(13393): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:795) 06-12 12:55:52.456: E/AndroidRuntime(13393): at dalvik.system.NativeStart.main(Native Method) 06-12 12:55:52.456: E/AndroidRuntime(13393): Caused by: java.lang.IllegalStateException: You must disable foreground dispatching while your activity is still resumed 06-12 12:55:52.456: E/AndroidRuntime(13393): at android.nfc.NfcAdapter.disableForegroundDispatchInternal(NfcAdapter.java:1170) 06-12 12:55:52.456: E/AndroidRuntime(13393): at android.nfc.NfcAdapter.disableForegroundDispatch(NfcAdapter.java:1156) 06-12 12:55:52.456: E/AndroidRuntime(13393): at com.chariotsolutions.nfc.plugin.NfcPlugin$3.run(NfcPlugin.java:273) 06-12 12:55:52.456: E/AndroidRuntime(13393): at android.app.Activity.runOnUiThread(Activity.java:4649) 06-12 12:55:52.456: E/AndroidRuntime(13393): at com.chariotsolutions.nfc.plugin.NfcPlugin.stopNfc(NfcPlugin.java:267) 06-12 12:55:52.456: E/AndroidRuntime(13393): at com.chariotsolutions.nfc.plugin.NfcPlugin.onPause(NfcPlugin.java:444) 06-12 12:55:52.456: E/AndroidRuntime(13393): at org.apache.cordova.api.PluginManager.onPause(PluginManager.java:284) 06-12 12:55:52.456: E/AndroidRuntime(13393): at org.apache.cordova.api.PluginManager.init(PluginManager.java:84) 06-12 12:55:52.456: E/AndroidRuntime(13393): at org.apache.cordova.CordovaWebView.loadUrlIntoView(CordovaWebView.java:410) 06-12 12:55:52.456: E/AndroidRuntime(13393): at org.apache.cordova.CordovaWebView.handleDestroy(CordovaWebView.java:809) 06-12 12:55:52.456: E/AndroidRuntime(13393): at org.apache.cordova.CordovaActivity.onDestroy(CordovaActivity.java:726) 06-12 12:55:52.456: E/AndroidRuntime(13393): at android.app.Activity.performDestroy(Activity.java:5255) 06-12 12:55:52.456: E/AndroidRuntime(13393): at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1135) 06-12 12:55:52.456: E/AndroidRuntime(13393): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3761) 06-12 12:55:52.456: E/AndroidRuntime(13393): ... 11 more

JohnMcLear commented 11 years ago
D:\>rm -rf foo

D:\>cordova create foo com.example.foo Foo

D:\>cd phonegap-nfc

D:\phonegap-nfc>git pull
remote: Counting objects: 97, done.
remote: Compressing objects: 100% (62/62), done.
remote: Total 90 (delta 53), reused 64 (delta 27)
Unpacking objects: 100% (90/90), done.
From git://github.com/chariotsolutions/phonegap-nfc
   a7a8130..3bae593  master     -> origin/master
Updating a7a8130..3bae593
Fast-forward
 INSTALL.md                           |  14 +++---
 README.md                            |   4 +-
 VERSION                              |   2 +-
 doc/GettingStarted.md                |  80 ++++++++++++++++++++++++++++++++++
 doc/GettingStartedCLI.md             |  81 +++++++++++++++++++++++++++++++++++
 doc/read_tag_1_basic_app.png         | Bin 0 -> 19688 bytes
 doc/read_tag_2_dump_tag.png          | Bin 0 -> 32218 bytes
 doc/read_tag_3_payload_as_string.png | Bin 0 -> 18191 bytes
 plugin.xml                           |  21 +++++----
 www/phonegap-nfc.js                  |   7 +++
 10 files changed, 191 insertions(+), 18 deletions(-)
 create mode 100644 doc/GettingStarted.md
 create mode 100644 doc/GettingStartedCLI.md
 create mode 100644 doc/read_tag_1_basic_app.png
 create mode 100644 doc/read_tag_2_dump_tag.png
 create mode 100644 doc/read_tag_3_payload_as_string.png

D:\phonegap-nfc>cd ..

D:\>cd foo

D:\foo>cordova plugin add ..\phonegap-nfc

D:\foo>cordova platform add android
Installing plugin com.chariotsolutions.nfc.plugin...
com.chariotsolutions.nfc.plugin installed.

D:\foo>

Looks good :)

JohnMcLear commented 11 years ago
D:\foo>cordova plugin add ..\phonegap-nfc
Plugin "com.chariotsolutions.nfc.plugin" already installed, 'sall good.

D:\foo>cordova plugin list

D:\foo>

list may be broken. Reported to Cordova guys on IRC

however

D:\foo>type platforms\android\assets\www\cordova_plugins.json
[{"file":"plugins\\com.chariotsolutions.nfc.plugin\\www\\phonegap-nfc.js","id":"com.chariotsolutions.nfc.plugin.NFC","runs":true}]
D:\foo>

So looks fine however..

<devgeeks>heh
<JohnMcLear_>for anyone who wants to create an issue ;)
<JohnMcLear_>also
<devgeeks>list will list plugins installed properly
<JohnMcLear_>cordova plugin add *second plugin* breaks functionality
<JohnMcLear_>it overrides cordova_plugins.json
<devgeeks>that error will get thrown for half-installed or badly removed ones
<JohnMcLear_>removes the previous reference

So my takeaway from this is that cordova plugin list is probably broken.

JohnMcLear commented 11 years ago

https://issues.apache.org/jira/browse/CB-3769 is the Apache issue tracker for this bug.

JohnMcLear commented 11 years ago

Hey @don I get Error on application exit still

Updated cordova to 2.8.15 Using latest phonegap-nfc

Steps to replicate: Follow the steps on https://github.com/chariotsolutions/phonegap-nfc/blob/master/doc/GettingStartedCLI.md Scan a tag Hit the BACK BUTTON.

This will cause the error, using the home button doesn't fire the same error..

Phew that was hard work.. Trace

06-12 21:35:24.910: E/AndroidRuntime(22775): FATAL EXCEPTION: main
06-12 21:35:24.910: E/AndroidRuntime(22775): java.lang.RuntimeException: Unable to destroy activity {com.example.foo/com.example.foo.Foo}: java.lang.IllegalStateException: You must disable foreground dispatching while your activity is still resumed
06-12 21:35:24.910: E/AndroidRuntime(22775):    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3112)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3130)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at android.app.ActivityThread.access$1200(ActivityThread.java:123)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1180)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at android.os.Looper.loop(Looper.java:137)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at android.app.ActivityThread.main(ActivityThread.java:4464)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at java.lang.reflect.Method.invokeNative(Native Method)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at java.lang.reflect.Method.invoke(Method.java:511)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:822)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:589)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at dalvik.system.NativeStart.main(Native Method)
06-12 21:35:24.910: E/AndroidRuntime(22775): Caused by: java.lang.IllegalStateException: You must disable foreground dispatching while your activity is still resumed
06-12 21:35:24.910: E/AndroidRuntime(22775):    at android.nfc.NfcAdapter.disableForegroundDispatchInternal(NfcAdapter.java:728)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at android.nfc.NfcAdapter.disableForegroundDispatch(NfcAdapter.java:714)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at com.chariotsolutions.nfc.plugin.NfcPlugin$3.run(NfcPlugin.java:273)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at android.app.Activity.runOnUiThread(Activity.java:4224)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at com.chariotsolutions.nfc.plugin.NfcPlugin.stopNfc(NfcPlugin.java:267)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at com.chariotsolutions.nfc.plugin.NfcPlugin.onPause(NfcPlugin.java:444)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at org.apache.cordova.api.PluginManager.onPause(PluginManager.java:284)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at org.apache.cordova.api.PluginManager.init(PluginManager.java:84)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at org.apache.cordova.CordovaWebView.loadUrlIntoView(CordovaWebView.java:410)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at org.apache.cordova.CordovaWebView.handleDestroy(CordovaWebView.java:809)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at org.apache.cordova.CordovaActivity.onDestroy(CordovaActivity.java:726)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at android.app.Activity.performDestroy(Activity.java:4683)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1079)
06-12 21:35:24.910: E/AndroidRuntime(22775):    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3099)
06-12 21:35:24.910: E/AndroidRuntime(22775):    ... 11 more
JohnMcLear commented 11 years ago

woohooo, was it easy to replicate? :) will try this..

JohnMcLear commented 11 years ago

Tested perfect, or so it seems. Any idea why this was missed/explanation so I know for debug purposes in future?

don commented 11 years ago

It has something to do with the way cordova manages the plugin lifecycle.

From watching the logs, cordova was calling nfcPlugin.onPause(true) then nfcPlugin.onPause(false) when the back button was hit.

The 2nd time onPause was called, the app was in the background, and the plugin was trying to disable foreground nfc dispatching, which causes an error if app isn't in the foreground.

JohnMcLear commented 11 years ago

Okies thanks :)

asnp87 commented 11 years ago

it works perfect! thanks :)