title: static method calls Toast.makeText
body: <p>I have a thread running in C++, it will call my UI thread's (Java) static method when some condition's satisfied. When the static method was called, I want a Toast to show on my UI. What I have tried are:</p>
  
  <p>1</p>
  
  <pre><code>     static void myMethod(){
          Toast.makeText(context, "message", Toast.LENGTH_SHORT).show();
          (I have a static context reference in global scope)
       }
  </code></pre>
  
  <p>RESULT:</p>
  
  <pre><code>     E/AndroidRuntime( 1331): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
  </code></pre>
  
  <p>2</p>
  
  <pre><code>     static void myMethod(){
           runOnUiThread(new Runnable(){
               public void run(){
                  Toast.makeText(Context, "message", Toast.LENGTH_SHORT).show();
               }
           });
  </code></pre>
  
  <p>RESULT: </p>
  
  <pre><code>   Can not compile: Cannot make a static reference to the non-static method runOnUiThread(Runnable) from the type Activity
  </code></pre>
  
  <p>Can anybody throw some light on this? Many thanks to you.</p>