Advertisement Jump to content
Sign in to follow this  
jujumbura

[Android] - Swapping Apps

This topic is 1753 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement

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().

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!