title: How to display Toast from a Service after main Activity finishes?
body: <p><strong>UPDATE:</strong>  I don't agree that this is a duplicate - because I am seeking for a way to exit the main app and still show a Toast from the service.</p>
  
  <p>In <a href="https://github.com/afarber/android-newbie/tree/q12/MyNotification/src/de/afarber/mynotification" rel="noreferrer">a very simple test app</a> I have 2 buttons:</p>
  
  <p><img src="https://i.stack.imgur.com/Zz9dz.jpg" alt="screenshot"></p>
  
  <p>Clicking any of the buttons will run a service with a corresponding action string ("open" or "flash") -</p>
  
  <p><a href="https://github.com/afarber/android-newbie/blob/q12/MyNotification/src/de/afarber/mynotification/OpenActivity.java" rel="noreferrer">OpenActivity.java</a>:</p>
  
  <pre><code>public class OpenActivity extends Activity {
      private Intent mServiceIntent;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_open);
          mServiceIntent = new Intent(this, RegionService.class);
     }
  
      public void openCar(View v) {
          mServiceIntent.setAction("open");
          startService(mServiceIntent);
      }
  </code></pre>
  
  <p><a href="https://github.com/afarber/android-newbie/blob/q12/MyNotification/src/de/afarber/mynotification/RegionService.java" rel="noreferrer">RegionService.java</a>:</p>
  
  <pre><code>public class RegionService extends IntentService {
      private static final String TAG = "RegionService";
  
      @Override
      protected void onHandleIntent(Intent intent) {
          Log.d(TAG, "Received an intent: " + intent);
          String action = intent.getAction();
          Log.d(TAG, "Received an action: " + action);
  
          if(action.equals("open")) {
              Toast.makeText(this, 
                      getString(R.string.car_opened), 
                      Toast.LENGTH_SHORT).show();
          } 
  </code></pre>
  
  <p>Unfortunately my app crashes with:</p>
  
  <pre><code>D/RegionService(24506): Received an intent: Intent { act=open cmp=de.afarber.mynotification/.RegionService }
  
  D/RegionService(24506): Received an action: open
  
  W/MessageQueue(24506): Handler (android.os.Handler) {422768a8} sending message to a Handler on a dead thread
  W/MessageQueue(24506): java.lang.RuntimeException: Handler (android.os.Handler) {422768a8} sending message to a Handler on a dead thread
  W/MessageQueue(24506):  at android.os.MessageQueue.enqueueMessage(MessageQueue.java:320)
  W/MessageQueue(24506):  at android.os.Handler.enqueueMessage(Handler.java:626)
  W/MessageQueue(24506):  at android.os.Handler.sendMessageAtTime(Handler.java:595)
  W/MessageQueue(24506):  at android.os.Handler.sendMessageDelayed(Handler.java:566)
  W/MessageQueue(24506):  at android.os.Handler.post(Handler.java:326)
  W/MessageQueue(24506):  at android.widget.Toast$TN.hide(Toast.java:370)
  W/MessageQueue(24506):  at android.app.ITransientNotification$Stub.onTransact(ITransientNotification.java:54)
  W/MessageQueue(24506):  at android.os.Binder.execTransact(Binder.java:412)
  W/MessageQueue(24506):  at dalvik.system.NativeStart.run(Native Method)
  </code></pre>
  
  <p>Being an Android programming newbie I wonder <strong>How to display a <a href="http://developer.android.com/guide/topics/ui/notifiers/toasts.html" rel="noreferrer">Toast</a> from Service in a correct way?</strong> </p>
  
  <p>I think I've already seen Toasts at Android Home (i.e. there was no Activity on the device screen and still there were Toasts).</p>
  
  <p><strong>My background:</strong> I would like to monitor a beacon device from my service and show some text Toasts - even when my app has been closed.</p>