[Solved] Screen Orientation Awareness

Put your problem here if it does not fit any of the other categories.

[Solved] Screen Orientation Awareness

Postby ben » Wed Jan 16, 2008 2:09 pm

How do you detect that the user has changed the orientation of the display screen from portrait to landscape and vice versa? The Android application must adjust to the new orientation. The system should be sending a change of orientation message to all open applications so that they can adjust. I could not find anything about this in the docs.

Connected to this problem, is there a way to make the Gallery widget scroll vertically instead of horizontally?

Thanks.
Ben
ben
Junior Developer
Junior Developer
 
Posts: 15
Joined: Thu Dec 13, 2007 3:23 am

Top

Postby plusminus » Wed Jan 16, 2008 5:57 pm

Hello ben,

I finally found what you were looking for:

Short Info:
CONFIGURATION_CHANGED_ACTION
Broadcast Action: The current device Resources.Configuration (orientation, locale, etc) has changed.


public static final String CONFIGURATION_CHANGED_ACTION
Broadcast Action: The current device Resources.Configuration (orientation, locale, etc) has changed. When such a change happens, the UIs (view hierarchy) will need to be rebuilt based on this new information; for the most part, applications don't need to worry about this, because the system will take care of stopping and restarting the application to make sure it sees the new changes. Some system code that can not be restarted will need to watch for this action and handle it appropriately.
See Also

* Resources.Configuration :src: (click)

Constant Value: "android.intent.action.CONFIGURATION_CHANGED"


But the Resources.Configuration does not seem to be completed (nothing about ScreenOrientation can be found there :(

So having received that Intent, you could check for Orientation-changes with this Class: DisplayMetrics: http://code.google.com/android/referenc ... trics.html

Hope I could help you.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby ben » Wed Jan 16, 2008 11:33 pm

Thanks plusminus.

One less problem. In that case, DisplayMetrics which provides width and height of screen will do the job for me.
Ben
ben
Junior Developer
Junior Developer
 
Posts: 15
Joined: Thu Dec 13, 2007 3:23 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: MSNbot Media and 11 guests