Question: I need to run some code when an App is launched and when it completely exits (is destroyed). I am using onCreate and onDestroy but unfortunately screen orientation changes destroys and recreates the activity.

Answer: 
Take a look at Android Application <http://developer.android.com/reference/android/app/Application.html>

You can know when Application created (Application.onCreated)

BUT you can't know when Application destroyed. Application.onTerminate() is only for use in emulated process environments.
Every time the app launched the `onCreate` method of your **launcher activity** is called. So you have to put the desired code in `onCreate` method of the Launcher activity.

And to detect whether your app is destroyed or not you can `override` `onDestroy` method ( just like adding the `onCreate` ) from **Override unimplemented method** menu. And put the codes inside of this method that you want to be executed when the app will be destroyed.