How to lock the landscape mode in j2me app?

℡╲_俬逩灬. 提交于 2019-12-01 05:59:10

问题


I want to show my app only in portrait mode. I have to restrict the landscape mode in my app.

There are separate attributes for each devices.

For Nokia, Nokia-MIDlet-App-Orientation : Portrait. For Samsung, MIDlet-ScreenMode : Portrait.

After adding these in JAD, I tried to install it in Nokia C5. I am unable to install it. I am getting Compulsory attribute missing error because custom JAD property shouldn't start with MIDlet-. I am unable to install it because of MIDlet-ScreenMode : Portrait property.

Is there any general code to lock the landscape mode in all devices like NOKIA, LG, Motorola, Samsung etc.,


回答1:


There is no way in MIDP to lock an app to an orientation. This is usually implemented via proprietary JAD parameters on different devices. You need to find out what these parameters are for the devices you wish to target and add them to your JAD.

Some methods to do this are in the answer to this question.




回答2:


If your apps GUI is implemented based on Canvas you can do it programatically. At this other answer Create Landscape Game Canvas for Asha 303 I show how to keep the landscape mode, but the same principle can be aplied to keep the app as portrait.




回答3:


It's a bit stressful but you could add an orientation listener and when the orientation changes, you could set the orientation value back to portrait.



来源:https://stackoverflow.com/questions/11098607/how-to-lock-the-landscape-mode-in-j2me-app

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