title: How to show custom error message in a Toast from Handler?
body: <p>I've created a custom handler that will take care of dismissing dialogs, showing dialogs and showing (custom) error messages. However, I'm stuck with the custom error message part. How do I post a message with custom message &amp; how to parse it in the handleMessage?</p>
  
  <p>Now I'm doing:</p>
  
  <p><code>handler.sendMessage(Message.obtain(handler, HANDLER_MESSAGE_ERROR));</code></p>
  
  <p>I've read about bundle, but didn't get it working. Preferably (to keep the code neat), I'd like to do something like this:</p>
  
  <p><code>handler.sendMessage(Message.obtain(handler, HANDLER_MESSAGE_ERROR, "Custom error message"));</code></p>
  
  <p>and for error dialog:</p>
  
  <p><code>handler.sendMessage(Message.obtain(handler, HANDLER_MESSAGE_DIALOG, "Custom title", "Custom error message"));</code></p>
  
  <p>Here's the handler code that I'm using right now:</p>
  
  <pre><code>public class MyHandler extends Handler {
      private Activity mContext;
  
      public MyHandler(Activity activity) {
          mContext = activity;
      }
  
      @Override
      public void handleMessage(Message msg) {
          switch (msg.what) {
          case MyActivity.HANDLER_MESSAGE_ERROR:
              try {
                  Toast.makeText(mContext, "_This should be a custom error message", Toast.LENGTH_SHORT).show();
              } catch (Exception e) {
  
              }
              break;
          }
      }
  }
  </code></pre>