J2ME Polish learning experience (a) ---- Device Optimization

Source: Internet
Author: User
Experience in a recent study J2ME, but soon found that a lot of headaches, for example, different devices of different hardware, jar and Jad automatic packing, Debug difficult, and so on. But then I found out that this be declared J2ME plish project, found out that he was all J2ME programming off dreams of things, so introduced me to everybody. J2ME Polish is of German an open-source project, the home page is http://www.j2mepolish.org/,类似于一个java开发环境的插件。 Be the first to introduce the equipment optimization function (Device Optimization ). For example, this too often, your MIDlet to voice, you know, to support mmapi or MIDP2.0 device can use the following methods: An Inputstream is = getClass (). getresourceasstream ("/mymid. mid "); Player player = Manager. createplayer (is, "audio/Midi"); the player. realize (); the player. start (); but MDIP1.0 mobile phone are also many, many mobile phones have their own API, for example, the Nokia UI, can Sound A = new Sound (400,1000);. setgain (100);. play (1); If you if your program in the two given phone, do, don't maintain two sets of source code? This is the trouble. So, I just want to if the Java in the similar to C ++ compilation of the pre-like, can do this: # If Device Support mmapi or MIDP2.0/do something here # Elif Device Support Nokia UI // do something diference here # endif and then the compiler can automatically generate different equipment of the class files as well. So the solution can be perfect, and J2ME Polish can help you do that, j2ME Polish to a certain extent, Java has a pre-function, the Code is as follows: // If Polish. midp2 | polish. API. mmapitry {An Inputstream is = getClass (). getresourceasstream ("/mymid. mid "); Player player = Manager. createplayer (is, "audio/Midi"); the player. realize (); the player. start ();} catch (mediaexception me) {// # debug error System. out. println ("Unable to play MIDI + me);} catch (IOException IE) {// # debug errorsystem. O Ut. println ("Unable to load MIDI + IE);} // # Elif polish. API. -Nokia UI Sound A = new Sound (400,1000);. setgain (100);. play (1 ); /# endif. I think the above code, I don't have to explain. You can read it, right? // If such is J2ME Polish will identify the pre-processing, in addition to "//", it in C ++ syntax is the same (/debug when J2ME Polish provide debug function, very powerful, English ). Polish. MIDP like is a predefined symbols and variables, j2me Polish definition rich symbols and variable, You can according to the equipment of the different platforms, the API, sound, image processing ability, to write the code. The target file is how to generate? J2ME Polish using ANT as compile management tool, in the build. in the XML, it's got a section: <requirement name = "Identifier" value = "Nokia/Series40, generic/midp2 ""/> how syntax is directly, it means that you want your application to produce corresponding to the two platforms, is the Nokia S40 and general support midp2's cell phone. J2ME Polish comes with a database, the device. XML, with all kinds of mobile phone type of the attribute information, so, when you compile, the last type of hardware will automatically use Nokia UI code, the latter is chosen to be midp2 code. How is not very good? There are a lot of very good, next time.

_ ICMs


_ ICMs




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.