I have a long-running thread which I start on app startup:
public class MyHelper extends Thread {
private AtomicBoolean mRun;
public void run() {
while (mRun.get()) {
...
}
}
}
public class App extends Application {
private MyHelper mHelper;
public void onCreate() {
mHelper = new MyHelper();
mHelper.start();
}
}
We don't get any "app terminate" signal in Android though, so is the above keeping my app running forever in the background? There's no good place for me to know when to shut the thread down.
I wonder if the user pops the last activity from the stack (by hitting the back button), will my Application instance get destroyed even though the Thread is still possibly in a waiting state?
Thanks