How to restrict j2me application in the Landscape mode only

依然范特西╮ 提交于 2019-12-06 06:17:48

问题


I am developing application using J2ME and LWUIT.I want to run this application on landscape mode only. For Nokia there is an attribute : Nokia-MIDlet-App-Orientation: landscape but for other device , What is the attribute to restrict the application to landscape mode only? How to achieve this for different J2ME devices?


回答1:


Following is the attribute to restrict application in landscape mode only.

Nokia device:

Nokia-MIDlet-App-Orientation : Landscape

Samsung device:

MIDlet-ScreenMode : Landscape



回答2:


If you want to lock the screen orientation in LWUIT, you must use a combination of the following methods.

Display.isPortrait() Returns true if the device is currently in portrait mode. Display.canForceOrientation() Returns true if the device allows forcing the orientation via code, feature phones do not allow this although some include a jad property allowing for this feature. Display.lockOrientation(boolean portrait)On devices that return true for canForceOrientation() this method can lock the device orientation either to portrait or landscape mode

I hope this can help you.




回答3:


I check the method Display.canForceOrientation() this give you the wrong answer because the value in the LWUITImplementation.java is hard coded and always return false. So in LWUIT if we want to restrict application the only way to do this is to add a JAD attribute through code it not possible.



来源:https://stackoverflow.com/questions/8708008/how-to-restrict-j2me-application-in-the-landscape-mode-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!