我是否可以通过startActivityForResult检测到第三方应用程序中的活动死亡这一事实?
04-30 17:07:28.408 4223-4634/? I/ActivityManager: Process com.citrix.mail.droid (pid 26179) has died(120,858)
出于某种原因,这个第三方邮件客户端一直在死,但仅限于这一部电话。它曾经在其他手机上工作和工作,所以这是一个特例。
未调用onActivityResult。
更新: 没有调用onActivityResult的原因是由于活动已经死亡。
原始日志 - 大量噪音 https://pastebin.com/MhFFEP7s
05-02 10:48:17.134 14781-14868/? E/AndroidRuntime: FATAL EXCEPTION: ContactsProviderWorker
Process: com.citrix.mail.droid, PID: 14781
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 1806): Could not open database
#################################################################
Error Code : 1806 (SQLITE_CANTOPEN_EACCES)
Caused By : Application has no permission to open the specified database file.
(unknown error (code 1806): Could not open database)
#################################################################
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:242)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:203)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:518)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:209)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:181)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1156)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1101)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:832)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:234)
at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187)
at citrixSuper.android.database.sqlite.SQLiteOpenHelper.ctx_getReadableDatabase(Unknown Source)
at citrixSuper.android.database.sqlite.SQLiteOpenHelper.getReadableDatabase_aroundBody2(Unknown Source)
at citrixSuper.android.database.sqlite.SQLiteOpenHelper.getReadableDatabase_aroundBody3$advice(Unknown Source)
at citrixSuper.android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(Unknown Source)
at com.citrix.contacts.providers.af.<init>(LegacyApiSupport.java:527)
at com.citrix.contacts.providers.ContactsProvider2.x(ContactsProvider2.java:1531)
at com.citrix.contacts.providers.ContactsProvider2.a(ContactsProvider2.java:1616)
at com.citrix.contacts.providers.ContactsProvider2$2.handleMessage(ContactsProvider2.java:1492)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
05-02 10:48:17.136 4223-8123/? D/Debug: !@DumpState : SHIP
05-02 10:48:17.136 4223-8123/? D/Debug: !@DumpState : debug level:0x4f4c
05-02 10:48:17.136 4223-8123/? D/Debug: !@Dumpstate : Finally, system will skip dumpstate
05-02 10:48:17.138 4223-8123/? W/ActivityManager: Force finishing activity com.citrix.mail.droid/com.citrix.email.activity.MessageCompose
05-02 10:48:17.138 4223-8123/? W/MultiScreenManagerService: moveTaskBackToDisplayIfNeeded(): The task has more than one activity
05-02 10:48:17.138 4223-8123/? D/ActivityManager: moveToFront() : reason=finishActivity adjustFocus setFocusedActivity isAttached=true TaskRecord{5c6b9ebd0 #4446 A=<my package>.stage U=0 StackId=1 sz=2}
05-02 10:48:17.141 4223-8123/? D/InputDispatcher: Focused application set to: xxxx
05-02 10:48:17.142 4223-8123/? D/InputDispatcher: Focus entered window: 14157
05-02 10:48:17.143 4223-8123/? D/ActivityTrigger: ActivityTrigger activityPauseTrigger
05-02 10:48:17.143 14157-14157/<my package>.stage D/ViewRootImpl@3ccd12b[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1
05-02 10:48:17.143 14157-14157/<my package>.stage D/ViewRootImpl@3ccd12b[MainActivity]: mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true -910002176}
05-02 10:48:17.143 4223-8123/? D/GameManagerService: sem_perfomance_mode: 3
05-02 10:48:17.144 4223-8123/? W/ActivityManager: Force finishing activity <my package>.stage/<my package>.main.MainActivity
05-02 10:48:17.144 4223-8123/? W/MultiScreenManagerService: moveTaskBackToDisplayIfNeeded(): root is not base activity
05-02 10:48:17.146 4223-8123/? D/ActivityManager: moveToFront() : reason=finishActivity adjustFocus setFocusedActivity isAttached=true TaskRecord{3f84085d0 #4326 I=com.sec.android.app.launcher/com.android.launcher3.Launcher U=0 StackId=0 sz=1}
05-02 10:48:17.146 4223-8123/? D/ActivityManager: setFocusStackUnchecked: reason=finishActivity adjustFocus setFocusedActivity focusCandidate=ActivityStack{8c48f5d0 stackId=0, 2 tasks} caller=com.android.server.am.ActivityStack.moveToFront:879 com.android.server.am.ActivityStackSupervisor.moveActivityStackToFront:2040
05-02 10:48:17.146 4223-8123/? W/MultiScreenManagerService: moveTaskBackToDisplayIfNeeded(): root activity or app is null
05-02 10:48:17.148 14157-14157/<my package>.stage V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@97c44ef nm : <my package>.stage ic=null
05-02 10:48:17.148 14157-14157/<my package>.stage I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
05-02 10:48:17.148 4223-4662/? D/InputMethodManagerService: windowGainedFocus mCurrentFocusedUserId - 0 and mSecureKeypadEnabled-false
05-02 10:48:17.150 4223-8123/? D/InputDispatcher: Focused application set to: xxxx
05-02 10:48:17.150 4223-4662/? V/InputMethodManagerService: windowGainedFocus: reason=WINDOW_FOCUS_GAIN client=android.os.BinderProxy@15d5431 inputContext=null missingMethods= attribute=android.view.inputmethod.EditorInfo@c6f32e nm = <my package>.stage controlFlags=#105 softInputMode=#110 windowFlags=#81810100
05-02 10:48:17.150 4223-4662/? V/InputMethodManagerService: Unspecified window will hide input
05-02 10:48:17.150 4223-4662/? V/InputMethodManagerService: hideCurrentInputLocked - !shouldHideSoftInput
05-02 10:48:17.150 4223-4662/? D/InputTransport: Input channel constructed: fd=314
05-02 10:48:17.150 4223-4662/? D/InputTransport: Input channel destroyed: fd=314
05-02 10:48:17.151 14157-14157/<my package>.stage D/InputTransport: Input channel constructed: fd=79
05-02 10:48:17.151 14157-14157/<my package>.stage D/InputTransport: Input channel destroyed: fd=78
05-02 10:48:17.151 4223-8123/? D/InputDispatcher: Focus left window: 14157
05-02 10:48:17.151 6099-6099/? I/SKBD: SamsungKeypad onFinishInput took nanoTime: 391731
05-02 10:48:17.151 6099-6099/? I/SKBD: SamsungKeypad [IMI] onStartInput - caller packageName : <my package>.stage
05-02 10:48:17.155 14157-14157/<my package>.stage D/ViewRootImpl@3ccd12b[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0
答案 0 :(得分:1)
我是否可以通过startActivityForResult检测到第三方应用程序中的活动死亡这一事实?
是。只要调用startActivityForResult
的活动处于活动状态,您就可以检测到它。如果活动本身被杀死,那么你就无法检测到任何东西。
如果活动明确返回,则resultCode将为RESULT_CANCELED ,在操作过程中没有返回任何结果,或崩溃。
您可以轻松查看此代码并采取必要步骤。
如果活动被强制完成怎么办
如果您的活动已完成,那么您无法控制它,因为此行为是由OS强制执行的。根据文档:
如果活动处于“已停止”状态且未长时间使用,或前台活动需要更多资源,系统也可能会销毁包含活动的进程以恢复内存。
您应该尝试按照定义的here步骤恢复活动。
此外,您可以创建SharedPreference
,您可以在其中存储boolean
标记,该标记可以包含以下值:
onActivityResult()
中重置)startActivityForResult()
之前设置)在onCreate()
中检查此值,以了解第三方应用是否会导致问题。
答案 1 :(得分:0)
当我意识到称为在线会话网络(与企业网络相关)的MDX策略时,startActivityForResult和setResult方法的连接断开。确实要发生的是,显示安全中心窗口并破坏我的活动。我发现是避免使用这些方法,但我仍然想使用活动方法onActivityResult。所以我做了:
服务提供商的官方支持团队对此一言不发(即使在与他们联系后也没说什么),但我认为应该将其作为文档的一部分,以使人们避免由于一项政策被开启而破坏应用程序。