I use a service in my cordova application that generates a startForeground notification in onCreate. If the application was killed with a swipe and started again, the cordova device ready event no longer fires. It seems that the cordova object itself is not detected when the application restarts. The following error message appears:
E/Web Console(19472): Uncaught TypeError: Object #<Object> has no method 'exec' at file:///android_asset/www/src/jsFile.js:31
Line 31 and the following:
cordova.exec(function (r) { if (callback) { callback(r); } }, function (err) { if (callback) { callback(false); } }, "Plugin", "functionName", []);
The problem only occurs if I use startForeground in my service, if I comment on this part of the code, that everything works correctly. I desperately need help on these issues:
- Can cordova handle be started manually?
- How to start a service using
startForeground , but still start the cordova-ready device after killing and restarting the application.
Edit:
After creating two quick project projects, one in Cordoba 3.6 (the version that I use for my actual application) and with Cordova 5.1, I realized that the problem does not occur in the new Cordoba version. However, I do not want to update because:
- Never touch a running system.
- I donโt know that it can never work in the version ever since I installed many plugins in my application.
- I'm lazy.
Any idea what could have changed from 3.6 to 5.1 that solved the error, and could I update my 3.6 code accordingly?
Edit2:
This is not a duplicate of this question . The deviceReady callback was mistaken in this question. This does not apply to my application, and it would be useless to work only when I do not use startForeground in my service.
android service cordova hybrid-mobile-app
Michael Kunst Aug 10 '15 at 9:50 2015-08-10 09:50
source share