防止Android上的屏幕旋转
问题描述:
我有一个活动要阻止,因为我正在启动AsyncTask,并且屏幕旋转使其重新启动.
I have one of my activities which I would like to prevent from rotating because I'm starting an AsyncTask, and screen rotation makes it restart.
有没有办法告诉此活动即使用户疯狂地摇晃手机也不要旋转屏幕"?
Is there a way to tell this activity "DO NOT ROTATE the screen even if the user is shaking his phone like mad"?
答
添加
android:screenOrientation="portrait"
或
android:screenOrientation="landscape"
到<activity>
个元素
清单,您就完成了.
to the <activity>
element/s in
the manifest and you're done.