2

I am trying to prevent users from closing my app when it is "recording" an activity (activity here is a hike, bike ride, run etc).

If I start recording and then go to another application then hit my "recent apps" button on the phone and hit "close all" or swipe my app off the screen, it destroys it and the recording is lost.

I obviously don't want to prevent users from closing it all the time, only when they start recording and then allow them to close it again when they've stopped.

I know this behavior can be done exactly like I want because the RD Client I use for my android device does exactly this...it won't allow me to close it while I'm connected to a remote machine but then does allow me to close it once I've disconnected.

I've searched high and low and can only find information of how to programatically remove an app from the recent apps list when it's closed.

any suggestions would be greatly appreciated.

Blair Holmes
  • 1,521
  • 2
  • 22
  • 35
  • instead of preventing your app from closing while it's recording, u can set it that when `onStop` is called, u save the recording in a database (sqlite or realm) and then close the app. this way, when the user re-opens the app, the recording can be retrieved from the database. – chornge Oct 06 '17 at 21:14
  • I'm already saving it to the database. The problem I'm trying to solve would happen when a user minimizes the app or opens another app then inadvertently closes my app by going to recent apps and hitting close all or swiping it off...I do that out of habit all the time. I want it to continue recording the activity until they actively decide to stop recording (by hitting a button within the app) – Blair Holmes Oct 06 '17 at 21:20
  • i have added an answer, i hope u find it useful – chornge Oct 06 '17 at 21:53

0 Answers0