当我的应用程序处于恢复过程中时,它在 Android 框架代码中崩溃。我无法重现崩溃,只能通过崩溃报告知道它。此外,崩溃发生在 Android 7、8、9 上,并在许多制造商之间传播。
这是android.os.RemoteException导致崩溃的堆栈跟踪:
com.android.server.am.ActivityManagerService.isTopOfTask(ActivityManagerService.java:14764) at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2417) at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3346) at android.os.Binder.execTransact(Binder.java:731)
上述异常是由 myActivity的super.onResume()调用触发的,然后引发了一个IllegalArgumentExceptionat
android.os.Parcel.createException + 1970 (Parcel.java:1970)
androidx.fragment.app.FragmentActivity.onResume + 514 (FragmentActivity.java:514)
最后,RuntimeException由于系统无法启动应用程序,因此捕获了上述异常。这是最后的堆栈跟踪:
android.app.ActivityThread.performResumeActivity + 4015 (ActivityThread.java:4015)
com.android.internal.os.ZygoteInit.main + 965 (ZygoteInit.java:965)
无码里面跑了我的onResume职能除了给呼叫super。
我尝试在有问题的情况下将应用程序置于后台/前台,Activity同时限制后台进程并打开“不要保持活动”,但我无法重现崩溃。
有没有人有重现崩溃的建议?
这是显示如何Service启动的代码:
@Singleton
class ExoplayerManager @Inject constructor(
@Application private val context: Context,
...
) : CastManager.CastEventListener {
private fun startService() {
lecture?.let {
val intent = ExoplayerService.createIntent(context, it.generateCompositeIdObject())
logd { "[ExoplayerService] startForegroundService called" }
ContextCompat.startForegroundService(context, intent)
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是关闭的代码 Service
public class ExoplayerService extends Service {
public static Intent createIntent(Context context, LectureCompositeId id) {
Intent intent = new Intent(context, ExoplayerService.class);
intent.putExtra(EXTRA_LECTURE_COMPOSITE_ID, (Parcelable) id);
return intent;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
String action = null;
LectureCompositeId lectureCompositeId = null;
if (intent != null) {
action = intent.getAction();
lectureCompositeId = intent.getParcelableExtra(EXTRA_LECTURE_COMPOSITE_ID);
}
L.leaveBreadcrumb(TAG, "onStartCommand >> startId: " + startId + " flags: " + flags +
" intent: " + intent + "action: " + action + " lectureCompositeId: " + lectureCompositeId);
// Actions are send by Notification and lock screen controls as intent params
if (intent != null) {
if (ACTION_SHUTDOWN.equals(action) || ACTION_SHUTDOWN_TASK.equals(action)) {
boolean fromNotification = intent.getBooleanExtra(EXTRA_SOURCE_NOTIFICATION, false);
attemptShutdown(startId, fromNotification, ACTION_SHUTDOWN_TASK.equals(action));
} else if (StringUtils.isNotBlank(action)) {
exoplayerManager.ensureLecture(lectureCompositeId);
handleNotificationMediaButtonAction(action);
} else {
initPlayerService();
}
}
return START_STICKY;
}
/**
* Queue a shutdown of the service. Ensures requests that need a notification have a chance to process.
*/
private void queueShutdown(boolean taskRemoved) {
Intent shutdown = new Intent(this, ExoplayerService.class);
if (taskRemoved) {
shutdown.setAction(ACTION_SHUTDOWN_TASK);
} else {
shutdown.setAction(ACTION_SHUTDOWN);
}
startService(shutdown);
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
// other methods
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2908 次 |
| 最近记录: |