有没有一种方法来检测设备方向事件或至少同时采用获得当前设备方向机器人:screenOrientation在清单?我的意思是设备方向不应用方向。
Is there a way to detect device orientation events or at least to get the current device orientation while using android:screenOrientation in the manifest ? I mean device orientation not application orientation.
我的问题是我的真的想保持我的波泰特模式的应用程序(这是一个web视图),但我想处理方向改变自己在我的应用程序。当机器人:screenOrientation是设置好的,方向由getted方法是总是应用取向,而不是设备方向。
My problem is I really want to keep my application in portait mode (it's a web view) but I want to handle orientation change myself in my app. When android:screenOrientation is setted, orientation getted by methods is always the application orientation, not the device orientation.
问候,加埃唐
Regards, Gaëtan
如果你想自己处理设备旋转,然后用下面的方法:
If you want to handle device rotation yourself, then use the following method:
@Override
public void onConfigurationChanged(Configuration config)
{
super.onConfigurationChanged(config);
Display display = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
if(display.getRotation() == Surface.ROTATION_90)
{
mFlash.startAnimation(mRotate);
}
if(display.getRotation() == Surface.ROTATION_90)
{
parameters.setPreviewSize(width, height);
}
if(display.getRotation() == Surface.ROTATION_180)
{
parameters.setPreviewSize(height, width);
}
if(display.getRotation() == Surface.ROTATION_270)
{
parameters.setPreviewSize(width, height);
mCamera.setDisplayOrientation(180);
}
}
里面的if语句仅仅是可以做例子的行动。显然,处理任何你需要在那里。
The actions inside the if statements are just examples of what might be done. Obviously, handle whatever you need to there.