android转屏处理
出自http://eigo.co.uk/News-Article.aspx?NewsArticleID=103
How to lock the orientation
In the onCreateDialog(int) event of the activity use the setRequestedOrientation(int) method to set the screen orientation to your chosen setting. The activity will stay in this orientation regardless of if the device is tilted or not.
[Code sample – How to lock the orientation] |
/**Calledwhentheactivityisfirstcreated.*/ |
How to detect the current orientation
To programmatically detect the current orientation of the activity use the following code snippet. The orientation property of the Configuration class returns three possible values corresponding to Landscape, Portrait and Square.
[Code sample – How to detect the current orientation] |
switch ( this .getResources () .getConfiguration () .orientation ) |
Example : Locking rotation while performing an action.
You might wish to disable the screen rotation whilst performing an action or by user command, to do this you need to combine the above samples to detect the current orientation and lock the display to that orientation.
[Code sample – Locking rotation while performing an action] |
//Setsscreenrotationasfixedtocurrentrotationsetting |
Once your action has completed you may wish to enable screen rotation again, see the next section for an example on how to do this.
How to re-enable screen rotation
To enable the orientation to be automatically changed on device tilt simply pass thesetRequestedOrientation(int) method the enumeration value for an unspecified orientation.
[Code sample – How to re-enable screen rotation] |
//allowscreenrotationsagain |
异步处理 的时候如果转屏 异步处理就会停止,附件就是防止这种情况发生
更多相关文章
- Android(安卓)Studio 使用技巧(1)
- Android(安卓)Studio 使用技巧(3)
- Android中事件处理之TouchListener实现步骤
- Android(安卓)图片透明度处理代码
- android ImageUtils 图片处理工具类
- android 添加对back按钮的处理,点击提示退出
- android HTTP 通信, XML 解析, 通过 Hander 实现异步消息处理
- android ImageUtils 图片处理工具类
- [转]处理各种触摸事件