Specifically, if I have a method running in my Activity class, then when the phone goes to sleep (CPU off), will the method run to completion before onPause() is called?
class MyActivity extends Activity {
...
public void doSomeWork() {
...
... // <-- Device goes to sleep at this point in time
...
return; // Do we get here before onPause() is called?
}
...
@Override
public void onPause() {
...
}
...
}
In addition to Activities, will a running thread (perhaps launched by an Activity class) be interrupted at whatever line of code it's at when the device goes to sleep? I see contradicting answers in this post: Does a Thread launched by Activity continue running once the device goes to sleep?
Going further, I understand that the Activity's onResume() will be invoked when the device wakes up; if doSomeWork() above or the aforementioned thread was indeed interrupted midway when going to sleep, will the remaining code resume?
Thanks in advance for any insight.