Jan 9

LastBreath or how to avoid losing the state of a game

Having a detailed report on any crash is great. Being able to send extra data and check the status of your app is even better. Being able to save necessary details and use them later is just awesome.

Let me give you a real life example. Suppose you have a platform game and you want to save the name of the player and his current state. For example: the points he has gathered and the level he has progressed. Wouldn’t be nice to save this information so that if a user restarts your game after a crash, they will be able to continue from where they were just before the crash?

image

Here’s where our ExceptionCallback feature for Android comes in!

In order to use this functionality you need only follow 3 small, easy steps.

1. Let your Activity implement BugSense’s ExceptionCallback. ex:

2. This will force you to add a public void method called lastBreath() in your code.

3. You should set your activity as the current ExceptionCallback.

This way you can have multiple lastBreath methods in different activities, but remember that only the activity that used the setExceptionCallback will be used.

Let’s see how you can implement this in your game now:

Here is the code for implentation with WindowsPhone8 as well.

There! Now your don’t have to lose a saved game ever again!! Check out our other blog posts for more tutorials and useful info, as well as our twitter page for news! 

And don’t forget, the BugSense team is always available to answer any questions you might have!