You must Login before you can answer or comment on any questions.
As reference, this is on Android.
I'm noticing this issue with several applications I've done with Appcelerator, all of them: no matter if they are simple apps or complex apps, but is more frequent in larger apps.
For example, I'm working on an application that needs to notify its location (GPS location) every 5 minutes. The application works perfectly when working in foreground, however, every time I put the app on the background (if I minimize the app by using the Home button) the application just crashes and all the services are stopped.
For notifying the application, here's the flow I'm using:
- When I start the application, I start an Alarm, using the AlarmManager module.
- This AlarmManager, adds a new Alarm Service, which will be triggered every 5 minutes.
- Every 5 minutes, the AlarmManager starts the service and notifies the server with the current location.
This works great.
If I hit the "Home" button, the application just crashes (on the Application Manager) sometimes, but is more frequent when using other applications on the foreground while leaving this app on the background.
I thought this was because the main Activity was stopped, so I decided to maintain the main activity / task state by using
If I reopen the application, the application just restarts. This happens more on low-end devices than on high-end devices, which makes me think that this is a memory issue.
Is this the expected behaviour? If so, how can I mitigate this? Is my current flow the best flow for doing this or is there a better approach?
Any thoughts are more than appreciated.
Think you can help? Login to answer this question!