Terminate the application

When the user closes the Good Citizen application, we need to do a bit of cleaning up to make sure the application shuts down properly. When the application receives a NAVIGATOR_EXIT event, the system directs the application to start shutting down. The application then has a certain amount of time (about 500 ms) to save its state and perform any additional cleanup operations. After this time has elapsed, the system will terminate the application if it is still running. To perform clean exits, you should avoid cleanup operations that take a long time (such as writing large amounts of data to a file).

In main(), after the application loop has exited due to user action, the first thing to do is stop requesting events from the screen.
screen_stop_events(screen_cxt);
Invoke bbutil_terminate(). This function cleans up the EGL setup by performing tasks such as destroying the EGL surface, context, and libscreen window.
bbutil_terminate();
Shut down the BlackBerry Platform Services (BPS) library, since we no longer need any of the library functions for our application. It's important to remember that after you perform this step, your application shouldn't call any other BPS functions.
bps_shutdown();
Destroy the screen context and exit the application.
screen_destroy_context(screen_cxt);
return 0;

That's it! You can now run and play with the Good Citizen application! You can try changing the behavior of the application to use different colors, change the menu text, or use a different shape for the object.

Last modified: 2015-03-31



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus