直接上代码:

Handler handler = new Handler(Looper.myLooper()) {
        @Override
        public void dispatchMessage(@NonNull Message msg) {
            super.dispatchMessage(msg);
            String message = msg.getData().getString("msg");
            Log.i("test", "msg:" + message);
        }
    };

调用:

String message = new String(body);
Message iMsg = handler.obtainMessage();
Bundle bundle = new Bundle();
bundle.putString("msg", message);
iMsg.setData(bundle);
handler.sendMessage(iMsg);

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
  • 2021-07-16
  • 2021-06-08
  • 2021-06-19
相关资源
相似解决方案