Not sure what you mean by "every time", but the general approach is something like this:
Ping & DNS - updated with new look and Ping home screen widget
Joined: Apr 23, 2013
thanks for answer
but for understanding oriention in evry time I must write this code in which method ? onCreate method or other ???
Joined: Mar 22, 2005
You need to check that wherever you need to know the orientation, and it might have changed in between. Usually the Activity is recreated if the orientation changes, though, so it should be sufficient to check in onCreate. But the app can be configured not to restart the Activity on orientation changes. So it all depends on how your app works, and how you want to handle orientation changes. Lots of information can be found in http://stackoverflow.com/questions/5914457/android-screen-orientation-reloads-activity (which I found by searching for "android screen orientation changes callback").