title: Show Complex Toast From BroadcastReceiver
body: <p>I wonder if someone can help me. I'm trying to display a toast element when an SMS is received. This toast should contain a layout which has an image (SMS Icon) and 2 textviews (sender, message)</p>
  
  <p>If I call the following method from an activity, it works as expected...</p>
  
  <pre><code>public void showToast(Context context, String name, String message) {
      LayoutInflater inflater = getLayoutInflater();
      View layout = inflater.inflate(R.layout.toast_sms,
                                     (ViewGroup) findViewById(R.id.toast_sms_root));
  
      TextView text = (TextView) layout.findViewById(R.id.toastsms_text);
      text.setText(message);
  
      Toast toast = new Toast(getApplicationContext());
      toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
      toast.setDuration(Toast.LENGTH_LONG);
      toast.setView(layout);
      toast.show();
  }
  </code></pre>
  
  <p>However, if I try to call the same code in the same way from my SMSReceiver, I get:</p>
  
  <pre><code>The method getLayoutInflater() is undefined for the type SmsReceiver
  The method findViewById(int) is undefined for the type SmsReceiver
  The method getApplicationContext() is undefined for the type SmsReceiver
  </code></pre>
  
  <p>Can someone please advise how I can do tihs from an intent. I assume the issue is somehow related to cross-threading however, I'm unsure how to proceed. I've seen a couple of examples online but they seem to either use deprecated code or only display simple text</p>
  
  <p>Can someone please point me in the correct direction</p>
  
  <p>Many thanks</p>