title: Showing toasts from a non-activity class. Ploblem setting the context to the toast
body: <p><em>Spoiler: this post may contain something stupid due to being used to C and new to Java programming</em></p>
  
  <p>There is an activity MainActivity and a public non-activity class containing a number of methods. I need to show toast alerts for some of them</p>
  
  <p>Current attempts are something like this, which fails with "Non-static method can not be referenced from a static context" for getApplicationContext():</p>
  
  <pre><code>void errorWarn (String warning) {
      Context context = android.content.ContextWrapper.getApplicationContext();
      Toast.makeText(context, "Something's wrong in " + warning, Toast.LENGTH_SHORT).show();
  }
  </code></pre>
  
  <p>So, how to call toasts from a non-activity class?</p>
  
  <p><strong>UPD</strong>: The errorWarn is to be called from the methods <em>in the class</em>. So, if an error in a method of the class occurs, there should be an alert</p>
  
  <p>We are in the MainActivity having an editText field. The class should get and parse the string from it. If on some step processing fails, it shows a toast in the MainActivity</p>
  
  <p><strong>UPD2</strong>: The full structure.</p>
  
  <p>MainActivity:</p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
      &lt;...&gt;
      public void ButtonClick (View view) {
          Class.testfunc("");
      }
  }
  </code></pre>
  
  <p>Class:</p>
  
  <pre><code>public class Class {
      void errorWarn (Context context, String warning) {
          Toast.makeText(context, "Something must be wrong. " + warning, Toast.LENGTH_SHORT).show();
      }
      void testfunc (String string) {
          errorWarn(string);
      }
  }
  </code></pre>