chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
712 stars 569 forks source link

nfc plugin does not retain the last view app #188

Closed pcalderoncity closed 8 years ago

pcalderoncity commented 9 years ago

Hi, i have installed the pluggin but I have a problem. it works correctly reading mifare tag when my phonegap app is showing but if I close it and I open it again does not keep the last view and my app login page appears.

any ideas? OS Android 4.1.2, Sony Xperia Thank you for your prompt reply.

allannaranjo commented 9 years ago

I don't think this is related to the plugin, what do you mean by the "login" page? I believe you might be asking about restore the state of your application which is unrelated to this plugin. Allan

On Monday, June 1, 2015, pcalderoncity notifications@github.com wrote:

Hi, i have installed the pluggin but I have a problem. it works correctly when my phonegap app is showing but if I close it and I open it again does not keep the last view and the login page appears.

any ideas?

Thank you for your prompt reply.

— Reply to this email directly or view it on GitHub https://github.com/chariotsolutions/phonegap-nfc/issues/188.

pcalderoncity commented 9 years ago

Thanks for your replay Allan, Excuse me for my english is not so good. I will try to explain what is my problem. My phonegap app works correctly restoring the last view but when I install the nfc plugin and it reads the card if I close the app and i open it again the last view is missing and the app loses the last state. I think that i am doing something wrong. Can you help me with any idea?

Thanks again.

don commented 9 years ago

@pcalderoncity I agree with @allannaranjo that this sounds more like an application state problem than a problem with phonegap-nfc.

Do you see any errors from your app if you view the logs with adb logcat or device monitor? If you remove the plugin, does your application retain state when you exit and re-open it? How does your application decide which page should be show? Are you overwriting this data after you read a nfc tag?

pcalderoncity commented 9 years ago

Hi Don, The logcat shows that my app calls again to the create method CordovaActivity.onCreate() and the life cicle starts again in my app login page.

Reading only one card the app loses the state. I do not why?. Obiously if I do not put the card the problem does not appear. The app loses the state when it reads the first card. My app is built with jquery using multi-page template, that is to say, multiple views in the same page.

For me is transparent the way that jquery or cordova handle the states, it works correctly by default.

I am new in the android world, I will appreciate any help.

Thanks Don.

don commented 9 years ago

So the login page appears after you scan a NFC tag? If that's the case, you may be doing something that causes the page to navigate, reloading the app. Look at the JavaScript where you're processing the nfcEvent. Look for javascript errors at runtime. Run jshint on your code.

Also look at the log before you see CordovaActivity.onCreate() are there any errors? If you see a Java stack trace, it's possible the plugin is causing an issue. Send me the details.

If you share your code I can take a quick look.

pcalderoncity commented 9 years ago

Thanks for your advice, I

will run the jshint tool but it should be noted that I commented the js lines where it set the nfc listener, therefore I think my personal code is not the problem. Just installing the plugin without the listener and put the card for reading originates my bug.

Line 1298 //nfc.addTagDiscoveredListener(_onNfc,function (status){alert(">>>>" + status);},function (error) { CM_SUBE_BAJA_OBJ.showMessage(MSG_NFC_ERR + JSON.stringify(error));});

Thanks for your attention.

Below my code: I am simplifying the code...

don commented 9 years ago

Rather than pasting code here, a github repo or gist would be better.

pcalderoncity commented 9 years ago

sorry, Can you take a look the code please? I had not compiled again https://gist.github.com/pcalderoncity/b1941d6bceb5dd38503a Thank you very much for your time.