java.lang.RuntimeException: Unable to resume activity {com.android.soundrecorder/com.android.soundrecorder.SoundRecorder}: java.lang.IllegalArgumentException
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3523)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3563)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1587)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6294)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: java.lang.IllegalArgumentException
at android.os.Parcel.readException(Parcel.java:1687)
at android.os.Parcel.readException(Parcel.java:1636)
at android.app.ActivityManagerProxy.isTopOfTask(ActivityManagerNative.java:5663)
at android.app.Activity.isTopOfTask(Activity.java:5963)
at android.app.Activity.onResume(Activity.java:1254)
at com.android.soundrecorder.SoundRecorder.onResume(SoundRecorder.java:516)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1269)
at android.app.Activity.performResume(Activity.java:6770)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3494)
... 8 more
异常堆栈
public final void readException() { int code = readExceptionCode(); if (code != 0) { String msg = readString(); readException(code, msg); } }
public final void readException(int code, String msg) { switch (code) { case EX_SECURITY: throw new SecurityException(msg); case EX_BAD_PARCELABLE: throw new BadParcelableException(msg); case EX_ILLEGAL_ARGUMENT: throw new IllegalArgumentException(msg); case EX_NULL_POINTER:frameworks\base\core\java\android\app\ActivityManagerNative.java
public boolean isTopOfTask(IBinder token) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(token); mRemote.transact(IS_TOP_OF_TASK_TRANSACTION, data, reply, 0); reply.readException(); boolean res = reply.readInt() == 1; data.recycle(); reply.recycle(); return res; }frameworks\base\services\core\java\com\android\server\am\ActivityManagerService.java
public boolean isTopOfTask(IBinder token) { synchronized (this) { ActivityRecord r = ActivityRecord.isInStackLocked(token); if (r == null) { throw new IllegalArgumentException(); } return r.task.getTopActivity() == r; } }
是由于r == null 导致远端返回抛出异常。
01-03 16:40:10.696 1160 1177 W ActivityManager: Activity stop timeout for ActivityRecord{8e16bb5 u0 com.android.soundrecorder/.SoundRecorder t12}
01-03 16:40:22.073 1160 1177 W ActivityManager: Activity destroy timeout for ActivityRecord{8e16bb5 u0 com.android.soundrecorder/.SoundRecorder t12 f}
activity stop timeout 会移除record 导致r == null
这里需要找出为什么 activity stop timeout