startActivityForResult and Back Stack
Asked Answered
B

0

6

Background : My app (A) is used by others app (B) to make an action on the behalf.

Expected result :

  • Crashing app B => Crash app A and all launched threads.
  • OR launhing app A activity on it's own app window.

Current behavior : startActivityForResult open the called activity of app A within app B (window), so when I crash app B the app A onDestroy baseActivity is called but not the threads launched by app A. Which not the case If I startActivity is used with singleTask as launchMode, hence with the later method I have the app A activity launched in app A window and not within app B window , so I could simulate the crash of app A and I have the expected result.

Based on this comment by Ian Lake it seems there is no way to launch the activity of app A in it's own app back stack.

[EDIT 1]

Wanna to share this information :

  • When I launch my app directly through launcher icon and kill it => the process is killed instantly.

  • When I launch my app through startActivityForResult => the process is killed after about 2/3 seconds.

Checked using :

adb shell
top -m 5
Broadleaf answered 11/12, 2019 at 22:42 Comment(3)
Could you start the new app with these intent flags? intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|FLAG_ACTIVITY_MULTIPLE_TASK)Millner
It work but the result isn't returned back to the caller app.Broadleaf
Your architecture sounds really hokey. If you are launching Threads, you should be using a Service not an Activity. Also, activities from different apps do not run in the same OS process and are very loosely coupled. Maybe you can explain more why you have this set up like you do?Fant

© 2022 - 2024 — McMap. All rights reserved.