Java类中打印this导致手机不能启动问题
Java类中打印this导致手机不能启动问题
问题1:发现在Handler中加类似Log.d(TAG,"create handler 1 "+ this);导致系统不能启动。
- public class Handler {
- public Handler() {
- if (FIND_POTENTIAL_LEAKS) {
- final Class<? extends Handler> klass = getClass();
- if ((klass.isAnonymousClass() || klass.isMemberClass() || klass.isLocalClass()) &&
- (klass.getModifiers() & Modifier.STATIC) == 0) {
- Log.w(TAG, "The following Handler class should be static or leaks might occur: " +
- klass.getCanonicalName());
- }
- }
- mLooper = Looper.myLooper();
- if (mLooper == null) {
- throw new RuntimeException(
- "Can't create handler inside thread that has not called Looper.prepare()");
- }
- mQueue = mLooper.mQueue;
- Log.d(TAG,"create handler 1 "+ this); //本行代码导致系统不能启动
- mCallback = null;
- }
- @Override
- public String toString() {
- return "Handler (" + getClass().getName() + ") {"
- + Integer.toHexString(System.identityHashCode(this))
- + "}";
- }
问题2:在Handler.toString中加打印this语句导致不能启动
- @Override
- public String toString() {
- Log.d(TAG,"this="+this);
- return "Handler (" + getClass().getName() + ") {"
- + Integer.toHexString(System.identityHashCode(this))
- + "}";
- }
评论暂时关闭