Handler myHandler = new Handler() { //此方法会在ui线程中执行 public void handleMessage(Message msg) { Context context = getApplicationContext(); CharSequence text = "Hello Handler! what="+msg.what; int duration = Toast.LENGTH_LONG; Toast.makeText(context, text, duration).show(); } }; Message msg = new Message(); msg.what = 1; myHandler.dispatchMessage(msg);