Jump to content

  • Log In with Google      Sign In   
  • Create Account

[Android] - Swapping Apps


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 jujumbura   Members   -  Reputation: 194

Like
0Likes
Like

Posted 04 April 2014 - 11:41 PM

I have been messing around with Android NDK development for a while now, and I just recently got an animation viewer up and running as a NativeActivity App on my Android device.  

 

One thing I was shocked to discover, though, is that when I hit the "Back" or "Home" buttons while running my device, my App is given the "APP_CMD_DESTROY" command, signaling it to exit the thread.  I had assumed that when leaving an App, it retains a memory space which is restored when you return to that App.  But from this behavior, it appears that my App will be restarted from scratch each time I enter and exit.

 

I read up a bit on the Android lifecycle, which seemed to confirm this behavior.  The intent seemed to be using the "savedState" buffer to handle the restore myself.  If this is really the intended flow, I now have a lot more respect for every native App that seamlessly transitions in and out.  But if this is really true, then I'm wondering:

 

1) What is the max limit on the savedState size?  I'm assuming I couldn't copy my entire allocated memory range, for example.

2) Assuming the above answer is fairly small, doesn't that imply that you need to reload all resources again?  This seems like it would involve tons of loading time, even for a brief transition back to the main menu.

 

It just seems like I must be missing something.  I'm curiow now how iOS handles this...

 

Thanks for any advice!



Sponsor:

#2 Ku134   Members   -  Reputation: 176

Like
0Likes
Like

Posted 05 April 2014 - 05:16 AM

In your app's manifest make sure that under the activity section you have the following line:

android:alwaysRetainTaskState = "true"

 You might also want to read up on - OnSaveInstanceState() and OnRestoreInstanceState().






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS