Writing one
Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
//todo 这里做一些事情。。。
}
};
This way of writing is actually not recommended, because the following method will be called first in the source code. If not, then this method will be called. This method is considered a spare tire method. In fact, the effect is the same. See your own habits.
Writing two
handler handler2 = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(@NonNull Message message) {
return false;
}
});