title: Android Application: Run code on a timer from the background
body: <p>hello everyone and thank you in advance.  My problem is that I have an app that the user will start in the foreground and will set a variable as a timer.  The user will most likely close that app, or the phone will go to sleep. So I need the app to background and then run code to send a notification when that timer hits 0.</p>
  
  <p>For the timer I would use unix time and have the background process check to see if it matched or the current time surpassed when the timer goes off. </p>
  
  <p>I would like to know - A) how to send the app to the background with these instructions
  B) how to then foreground the app, or at least be able to send a notification after running some code</p>
  
  <p>Again, thank you very much, let me know if I was not clear or if I missed someone's previous thread.</p>