onConfigurationChanged没有得到所谓的 [英] onConfigurationChanged not getting called

查看:233
本文介绍了onConfigurationChanged没有得到所谓的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天早上我想出了一个问题,试图处理 onConfigurationChanged 事件。问题是,该方法,该方法我重写,不获取调用时予改变电话的取向。没有得到所谓的。

This morning I came up with a problem trying to handle the onConfigurationChanged event. The problem is that the method, which I override, is not getting called when I change the orientation of the phone. Not getting called at all.

我已经把安卓configChanges =定向在清单中定义提到对Android的文件,但是这不有所作为的活动。

I've put android:configChanges="orientation" on the activity defined in the manifest as mentioned on the android documentation, but this don't make a difference.

你有没有想出这个问题呢?

Have you come up with this problem?

推荐答案

问题是,如果你使用这个方法

The problem was that if you use this method

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

要强迫你的活动,以纵向模式的方向,你没有候选人获得的方向变化。

to force the orientation of your activity to portrait mode, you're not candidate to receive orientation changes.

所以解决方案是不setRequestOrientation到特定模式。而是使用SCREEN_ORIENTATION_SENSOR。

So the solution is to not setRequestOrientation to a particular mode. But instead use SCREEN_ORIENTATION_SENSOR.

这篇关于onConfigurationChanged没有得到所谓的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆