I am writing a program that continuously records audio in the background and will fill continually fill a buffer with that data so that processing can be performed on it.
So this part of the program works; the app will run in the background even when the device is in sleep mode. However, after a set amount of time (maybe 1 or 2 hours?) the app will suddenly stop running and may even restart.
The continuous audio recording and processing is performed using an extension of AsyncTask. Is there anyway to keep this program running indefinitely and what is the procedure for it? It runs indefinitely up until a point; I don’t want it to turn off unless the user requests.
Urk. Please don’t use AsyncTask! Instead, use IntentService, which runs on a separate thread in the background. It shouldn’t be shut down in normal circumstances, even when the device is in sleep. Basically, it will run as long as its main method onHandleIntent() is running, and that will run until it finishes all its statements.