Keep alive Service in background? <p>For a demo I print a Toast after Evert 10 sec. using <code>Service</code> class. </p> <p>It works fine, I'm getting the Toast after every 10 sec if I am on the Activity when I leave the app, Service is not giving the o/p.</p> <p><strong>But I want to that toast either I'll kill the App or back press</strong> Here is code snippet :</p> <p><em>ServiceDemo.java</em></p> <pre><code>public class ServiceDemo extends Activity { private Handler myHandler = new Handler(); private Runnable drawRunnable = new Runnable() { @Override public void run() { as(); myHandler.postDelayed(this, 10000); } }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_service_demo); myHandler.postDelayed(drawRunnable, 10000); startService(new Intent(this, MyService.class)); } public void as(){ startService(new Intent(this, MyService.class)); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); } } </code></pre> <p><em>Service.java</em></p> <pre><code>public class MyService extends Service { @Override public IBinder onBind(Intent intent) { return null; } @Override public void onCreate() { Toast.makeText(this, "HOHO Service Created...", Toast.LENGTH_LONG).show(); } @Override public void onDestroy() { } @Override public void onStart(Intent intent, int startid) { Toast.makeText(this, "Service Started...", Toast.LENGTH_LONG).show(); } } </code></pre> <p><strong>Edit 1</strong></p> <pre><code> moveTaskToBack(true); </code></pre> <p>I put this into the onBackPressed method I Service give the o/p if I am not on the screen but When I kill the App, <code>Service not responding</code></p>