改成这样就行了

..
public class BaseActivity extends AppCompatActivity {
    protected MyHandler mHandler;
    
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
       ..
       mHandler = new MyHandler(this);
       ..     
   }
    
    /**
     * 内部类使用Handler造成内存泄露
     */
    protected static class MyHandler extends Handler {
        private WeakReference<BaseActivity> mActivity;
    
        private MyHandler(BaseActivity baseActivity) {
            mActivity = new WeakReference<>(baseActivity);
        }
    
        @Override
        public void handleMessage(@NonNull Message msg) {
            if (mActivity.get() == null) {
                return;
            }
            mActivity.get().myHandleMessage(msg);
        }
    }

    protected void myHandleMessage(Message msg) {
    }    
}