如何全局锁定Android设备的屏幕方向 [英] How to globally lock Android device screen orientation
本文介绍了如何全局锁定Android设备的屏幕方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要锁定屏幕横向或爱国者模式我的Android设备上的所有应用程序。
我应该做什么禁用自动屏幕方向身边?
我检查了从Android Market部分应用和尝试看看他们做什么。
看来这些应用程序创建一个服务窗口管理操作这样的。
窗口管理WM =(窗口管理器)getSystemService(CONTEXT.WINDOW_SERVICE);
CustomLayout CL =新CustomLayout(desire_orientation);
查看localView =新的视图(本);
wm.addView(localView,CL);
但是,当我不能做这样的事情。任何想法?
另外,我能够改变框架code,从Java到C ++,任何其他方式做到这一点?
解决方案
WindowManager.LayoutParams PARAMS =新WindowManager.LayoutParams();
params.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
wm.addView(localView,则params);
这对我的作品。
I want to lock screen to landscape or patriot mode for all apps on my Android device. What should I do beside disable auto screen orientation?
I have check out some apps from android market and try to see what they do. It seems those apps create an service to manipulate WindowManager like this.
WindowManager wm = (WindowManager)getSystemService(CONTEXT.WINDOW_SERVICE);
CustomLayout cl = new CustomLayout(desire_orientation);
View localView = new View(this);
wm.addView(localView, cl);
But when I fail to do something like this. Any idea?
Also, I am able to change framework code, from Java to C++, any other way to do this?
解决方案
WindowManager.LayoutParams params = new WindowManager.LayoutParams();
params.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
wm.addView(localView, params);
this works for me.
这篇关于如何全局锁定Android设备的屏幕方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文