Pure Java implementation of Android Handler. This is helpful to test Android Handler based logic in a pure Java project.
Use DelayQueue
internal to implement the MessageQuue
.
The project is still working, and most of the Android Handler related apis will be completed later on.
It has been deployed to mavenCentral:
implementation("com.bennyhuo:portable-android-handler:1.0")
First you should setup your own looper thread like what Android does in ActivityThread
:
Looper.prepare();
// Create a new Thread to use your handler here.
Looper.loop();
//unreachable unless you quit the looper.
This library is mentioned in my Android Interview Tutorials: 破解Android高级面试