• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How get screenOrientation in activity?

 
Farshad Zeinali
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi dears
How do I can get phone screenOrientation in activity in evry time ?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what you mean by "every time", but the general approach is something like this:

 
Farshad Zeinali
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for answer

but for understanding oriention in evry time I must write this code in which method ? onCreate method or other ???
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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").
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic