简体   繁体   English

Android startActivityForResults 并在异常时返回调用应用程序

[英]Android startActivityForResults and returning to calling applications on exceptions

currently i have an application that is called from an external application目前我有一个从外部应用程序调用的应用程序
The flow is as followed:流程如下:

External -> A -> B -> C -> External (With data) this is done by retaining A and when C finishes, we return to A and call setResult and finish() in A. External -> A -> B -> C -> External (With data) 这是通过保留 A 完成的,当 C 完成时,我们返回到 A 并在 A 中调用 setResult 和 finish()。

This works fine for most of the use case except if there's a crash somewhere in the process.这适用于大多数用例,除非过程中某处发生崩溃。 So for example例如

External App -> A -> B -> C (CRASHES HERE) It will return to B instead of going back to the external application. External App -> A -> B -> C (CRASHES HERE) 它将返回到 B 而不是返回到外部应用程序。 this is problematic for my use-case as it's an integrated environment without user interaction.这对我的用例来说是有问题的,因为它是一个没有用户交互的集成环境。

I have tried overwriting the DefaultExceptionHandler however have not had any luck in trying to get the correct flow.我曾尝试覆盖 DefaultExceptionHandler 但是没有任何运气来尝试获得正确的流程。 Is there a way to return to the calling application always on a crash?有没有办法总是在崩溃时返回到调用应用程序?

So far I found using activity.getCallingActivity() and I am calling startActivity with this component.到目前为止,我发现正在使用 activity.getCallingActivity() 并且正在使用此组件调用 startActivity。 it appears to work.它似乎工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM