android - 以编程方式锁定某些操作的纵向模式

标签 android

有没有办法以编程方式将应用程序锁定为纵向模式以执行某些操作,然后在操作完成后恢复(如果用户以这种方式握住设备,则让应用程序旋转到横向)?

最佳答案

试试这个:

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//Do your operation
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);

关于android - 以编程方式锁定某些操作的纵向模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6654675/

相关文章:

Androidx 测试 - 如何在调用 onCreate 之前设置 Activity 属性

android - File.createTempFile() VS 新文件()

android - 当上传到 playstore : ResTable header size 0x0000 is too small

android - 应用内结算接收者权限

java - Xamarin、Android Activity 、IntentFilter、打开表单 View

Android SDK 管理器在选择存储库时出现 "Failed to fetch URL https://dl-ssl.google.com/android/repository/repository.xml"错误

android - 自定义样式属性始终默认设置

android - 如何在您自己的 Android 应用程序中使用谷歌帐户?

android - 名称错误 : name 'TRUE' is not defined PIR sensors

android - 包含图像的 SlidingDrawer