java.lang.RuntimeException: Unable to resume activity with java.lang.IllegalArgumentException

后端 未结 2 448
半阙折子戏
半阙折子戏 2021-01-30 05:10

Recently I sometimes got this exception when MainActivity called onResume().

java.lang.RuntimeException: Unable to resume activity {com.qau4d.c35s3.androidapp/co         


        
2条回答
  •  轮回少年
    2021-01-30 05:25

    In the method Activity#isTopOfTask we can see:

    private boolean isTopOfTask() {
        if (mToken == null || mWindow == null) {
            return false;
        }
        try {
            return ActivityManager.getService().isTopOfTask(getActivityToken());
        } catch (RemoteException e) {
            return false;
        }
    }
    

    And in ActivityManagerService#isTopOfTask we can found:

    @Override
    public boolean isTopOfTask(IBinder token) {
        synchronized (this) {
            ActivityRecord r = ActivityRecord.isInStackLocked(token);
            if (r == null) {
                throw new IllegalArgumentException();
            }
            return r.task.getTopActivity() == r;
        }
    }
    

    So, I think that ActivityRecord is null.But I don't know why it is null....

提交回复
热议问题