ray-note/Bug日志/Android 错误记录.md

7 lines
516 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### Android 中 Handler 的message处理
Android 中的Handler的handleMessage中处理数据时如果收到message的频率比较高就容易出现新的消息通知时获取到的是旧数据这个时候可以把 handleMessage 中的处理逻辑使用协程,`切换到Dispatchers.IO` 中尽心处理如果过程有需要在主线程中执行的代码再切换到Dispatchers.Main中执行。
> Android 中的Handler 中需要使用的线程是有创建时传入的Looper决定的。
---