File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes How get screenOrientation in activity? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "How get screenOrientation in activity?" Watch "How get screenOrientation in activity?" New topic
Author

How get screenOrientation in activity?

Farshad Zeinali
Greenhorn

Joined: Apr 23, 2013
Posts: 17
hi dears
How do I can get phone screenOrientation in activity in evry time ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
Not sure what you mean by "every time", but the general approach is something like this:


Ping & DNS - my free Android networking tools app
Farshad Zeinali
Greenhorn

Joined: Apr 23, 2013
Posts: 17
thanks for answer

but for understanding oriention in evry time I must write this code in which method ? onCreate method or other ???
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
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").
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How get screenOrientation in activity?