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.