How can I globally force screen orientation in Android? -


there number of apps able force screen rotation. work if app explicitly wants viewed in orientation. right disabling accelerometer rotation system setting , setting preferred orientation. app can still override this.

here 1 of apps able override app's requested orientation:

https://play.google.com/store/apps/details?id=nl.fameit.rotate&hl=en

i tried kagronick's answer couldn't make work. after messing around bit got working using system overlay window , removing layoutparams found unnecessary. here's eventual solution:

orientationchanger = new linearlayout(this); // using type_system_overlay crucial make window appear on top // you'll need permission android.permission.system_alert_window windowmanager.layoutparams orientationlayout = new windowmanager.layoutparams(windowmanager.layoutparams.type_system_overlay, 0, pixelformat.rgba_8888); // use whatever constant need desired rotation orientationlayout.screenorientation = activityinfo.screen_orientation_sensor;  windowmanager wm = (windowmanager) this.getsystemservice(service.window_service); wm.addview(orientationchanger, orientationlayout); orientationchanger.setvisibility(view.visible); 

you can see success in app released based on this: force dock rotation.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -