标签:android style blog http io os 使用 java ar
private void showToastByRunnable(final IntentService context, final CharSequence text, final int duration) { Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { Toast.makeText(context, text, duration).show(); } }); }
Handler msgHandler = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(Message msg) { Toast.makeText(ToastIntentService.this, msg.getData().getString("Text"), Toast.LENGTH_SHORT).show(); super.handleMessage(msg); } }; private void showToastByMsg(final IntentService context, final CharSequence text, final int duration) { Bundle data = new Bundle(); data.putString("Text", text.toString()); Message msg = new Message(); msg.setData(data); msgHandler.sendMessage(msg); }
Service和IntentService中显示Toast的区别
标签:android style blog http io os 使用 java ar
原文地址:http://www.cnblogs.com/mrgong/p/3983325.html