开发者

Change Orientation from background in android

I have this requirement where i am suppose to change the orientation of the display after a certain number of ticks , this may well happen even when my app is not in foreground.

How do i do this ??

I looked around a bit and found WindowManagerService.java has a "setRotation" API

I rooted my app but even now i dont see any change in oreintation even on home screen.. please any help开发者_如何学C

this is how i m calling the API.

private IWindowManager iwm; 
iwm = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
iwm.setRotation(orent,true,0)

please note the value of "orent" is cycled from 0 to 3 (1st time called with 0 then, 1 then 2 ....) still i never see any change in orientation .. Is there some non technical issue like settings etc or I m not the proper API's ? Im using Froyo codebase


It doesn't make sense to change the UI of an activity if it is not in the foreground. If the orientation changes are time based, it should be easy to calculate which orientation your activity should be in when it returns to the foreground. Just add some logic in onResume and load the correct layout then.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜