问题描述
是否可以检测屏幕旋转?我的意思是 - 仅轮换,这与活动初始化与另一个活动有明显区别?
is it possible to detect screen rotation? I mean - rotation only, which is clearly distinguishable from activity initialization from another activity?
onXxx 方法似乎对此没有用,我尝试从 starting Intent 添加/删除 flag (删除似乎没有反映,在旋转标志在那里),并尝试为清单中的活动添加 android:configChanges="orientation" ,但是 onConfigurationChanged 方法似乎每秒钟旋转一次...有线.
The onXxx methods seem not to be useful for this, I have tried adding/removing a flag from the starting Intent (the removing seems not to be reflected, on rotate the flag is there), and have tried adding android:configChanges="orientation" for the activity in the manifest, however the onConfigurationChanged method seems to be called every second rotation... wired.
我想我遗漏了一些东西......但在其他相关线程中没有找到明确的解决方案.
I guess I am missing something... but haven't found clear solution in the other related threads.
有什么想法吗?
推荐答案
清单:
<activity android:name=".MyActivity" android:configChanges="screenSize|orientation|screenLayout|navigation"/>
活动:
@Override
public void onConfigurationChanged(Configuration newConfig)
{
Log.d("tag", "config changed");
super.onConfigurationChanged(newConfig);
int orientation = newConfig.orientation;
if (orientation == Configuration.ORIENTATION_PORTRAIT)
Log.d("tag", "Portrait");
else if (orientation == Configuration.ORIENTATION_LANDSCAPE)
Log.d("tag", "Landscape");
else
Log.w("tag", "other: " + orientation);
....
}
也试试这个链接
如何检测屏幕旋转
这篇关于如何检测屏幕旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

![[ios.cocos2d+box2d]如何禁用自动旋转? [ios.cocos2d+box2d]如何禁用自动旋转?](/assets/images/default.png)
大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)