Leonardo
Leonardo

Reputation: 1363

Prevent app closing after calling an external app

It's been a while since I coded for Android so I actually dunno if there's a way to set a life cycle end time (be kind :)).

The point is: my app needs to open PDF files in Adobe Reader. User can just check if it's the right file (open it for a few seconds or minutes) or read it all (keep it open for several minutes or a few hours). Is there any way to prevent my app, the one which called Adobe Reader, of close?

Upvotes: 0

Views: 129

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006744

Is there any way to prevent my app, the one which called Adobe Reader, of close?

Not really.

Your app, when it is not in the foreground, can have its process be terminated at any time, as Android looks to free up system RAM to run other processes. This is important, as most Android devices have nowhere near enough system RAM to run everything that needs to be run. This has nothing specifically to do with your launching a PDF viewer; if the user presses HOME, or takes an incoming phone call, or responds to a Notification in the status bar, your app moves to the background, and your process can be terminated.

Well-written apps fall into two categories:

  • Those that are actively delivering value to the user while the app is not in the foreground (e.g., music player). These use services to tell Android that the app is delivering value.

  • Those that are not doing anything while the app is in the background. These apps save their state in files and, secondarily, in the saved instance state Bundle supplied to activities and fragments. Those Bundle contents will be handed back to you if the user returns relatively quickly to your app (say, within half an hour).

Upvotes: 1

Related Questions