Flashlight program on midp2.0 mobile phone (with code)

Source: Internet
Author: User

Flashlight on midp2.0 mobile phoneProgram(AppendixCode)

Author: Chen yuefeng

From: http://blog.csdn.net/mailbomb

You can run the flashlight program on all mobile phones that support midp2.0. The principle of the program is to use the Display object to control the background of the mobile phone. In this series of mobile phones, only the function of flashing the background light can be realized. The implementation code is as follows:

// File name: lightmidlet. Java

Package light;

Import javax. microedition. MIDlet .*;
Import javax. microedition. lcdui .*;

Public class lightmidlet extends MIDlet {
Static lightmidlet instance;
Lightform displayable = new lightform (this );
Public lightmidlet (){
Instance = this;
}

Public void Startapp (){
Display. getdisplay (this). setcurrent (displayable );
}

Public void pauseapp (){
}

Public void destroyapp (Boolean unconditional ){
}

Public static void quitapp (){
Instance. destroyapp (true );
Instance. policydestroyed ();
Instance = NULL;
}

}

// File name: lightform. Java

Package light;

Import javax. microedition. lcdui .*;

Public class lightform extends form implements commandlistener {
Stringitem Si;
Command cmdopen;
Command invocation close;
Command cmdexit;
Display display;
Public lightform (lightmidlet lm ){
Super ("Flashlight ");
SI = new stringitem ("Flashlight status:", "open ");
This. append (SI );

Display = display. getdisplay (LM );

Cmdopen = new command ("open", command. OK, 1 );
This. addcommand (cmdopen );

Closing close = new command ("close", command. Cancel, 1 );
This. addcommand (writable close );

Cmdexit = new command ("quit", command. Exit, 1 );
This. addcommand (cmdexit );

Setcommandlistener (this );

Boolean B;

B = display. flashbacklight (1000000 );

If (B = false ){
Alert = new alert ("Flashlight", "your mobile phone does not support this function! ", Null, alerttype. info );
Alert. setTimeout (3000 );
Display. setcurrent (alert );
}
}

Public void commandaction (command C, displayable d ){
// Close
If (C = cmdexit ){
// Stop the MIDlet
Lightmidlet. quitapp ();
}
// Open
If (C = cmdopen ){
Display. flashbacklight (1000000 );
Si. settext ("open ");
}

If (C = closing close ){
Display. flashbacklight (0 );
Si. settext ("close ");
}
}

}

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.