title: Display Toast from within static method in Android
body: <p>I wish to display a toast to the screen when a certain condition is met within my static method as shown below:</p>
  
  <pre><code>public static void setAuth(String a) {
  
      String[] nameparts1;
  
      if (a.trim().isEmpty()) {
          author = "Author's Name";
          firstinit1 = "Initial";
          surname1 = "Surname";
      }
  
      if (a == 'X') {
          Toast ifx = Toast.makeText(getApplicationContext(), "Please enter name in correct format.", Toast.LENGTH_SHORT);
          ifx.show();
      }
  }
  </code></pre>
  
  <p>However this gives me the error: 'Cannot make a static reference to the non-static method getApplicationContext() from the type ContextWrapper'.</p>
  
  <p>Hopefully I have provided enough information here. Any help would be much appreciated!</p>