I have an app that uses a service in the background to do some upload/download operations.
These operations can take some time, depending on the user selection (amount and size of files).
While with my device (nexus s) and in the testing emulator, all works as planned, I am getting reports from users that the operation gets stuck sometimes when choosing to upload/download big data.
The operation is done using a thread that runs in a background service. My guess is that the OS sometimes kills the thread and/or service on devices with low memory.
In the service onStartCommand() function I am raising the thread that will do the operation (the data to handle comes within the intent), then I am returning START_NOT_STICKY.
At the activity I am using startService(i), no binding is done.
How can prevent this? How can I ensure the system will not kill either my service or thread?
The use of startForeground() may help you achieving your goal.
From docs: