کد:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Oep;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author AHA
*/
public class RingZer0 extends MIDlet implements CommandListener {
private boolean midletPaused = false;
//<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
private Command exitCommand;
private Command okCommand;
private Command helpCommand;
private Command okCommand1;
private Form Main;
private StringItem stringItem;
private StringItem stringItem1;
private TextField textField;
private Spacer spacer;
private StringItem stringItem2;
//</editor-fold>//GEN-END:|fields|0|
/**
* The HelloMIDlet constructor.
*/
public RingZer0() {
}
//<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
//</editor-fold>//GEN-END:|methods|0|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
/**
* Initilizes the application.
* It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
*/
private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
// write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize
// write post-initialize user code here
}//GEN-BEGIN:|0-initialize|2|
//</editor-fold>//GEN-END:|0-initialize|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
/**
* Performs an action assigned to the Mobile Device - MIDlet Started point.
*/
public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
// write pre-action user code here
switchDisplayable(null, getMain());//GEN-LINE:|3-startMIDlet|1|3-postAction
// write post-action user code here
}//GEN-BEGIN:|3-startMIDlet|2|
//</editor-fold>//GEN-END:|3-startMIDlet|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
/**
* Performs an action assigned to the Mobile Device - MIDlet Resumed point.
*/
public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
// write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
// write post-action user code here
}//GEN-BEGIN:|4-resumeMIDlet|2|
//</editor-fold>//GEN-END:|4-resumeMIDlet|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
/**
* Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
* @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
* @param nextDisplayable the Displayable to be set
*/
public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
// write pre-switch user code here
Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
if (alert == null) {
display.setCurrent(nextDisplayable);
} else {
display.setCurrent(alert, nextDisplayable);
}//GEN-END:|5-switchDisplayable|1|5-postSwitch
// write post-switch user code here
}//GEN-BEGIN:|5-switchDisplayable|2|
//</editor-fold>//GEN-END:|5-switchDisplayable|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
/**
* Called by a system to indicated that a command has been invoked on a particular displayable.
* @param command the Command that was invoked
* @param displayable the Displayable where the command was invoked
*/
public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
// write pre-action user code here
if (displayable == Main) {//GEN-BEGIN:|7-commandAction|1|19-preAction
if (command == exitCommand) {//GEN-END:|7-commandAction|1|19-preAction
// write pre-action user code here
exitMIDlet();//GEN-LINE:|7-commandAction|2|19-postAction
// write post-action user code here
} else if (command == okCommand) {//GEN-LINE:|7-commandAction|3|22-preAction
// write pre-action user code here
//GEN-LINE:|7-commandAction|4|22-postAction
// write post-action user code here
String s;
if((s = System.getProperty("com.nokia.mid.imei")) == null)
s = System.getProperty("com.nokia.IMEI");
if(s == null)
s = System.getProperty("phone.imei");
if(s == null)
s = System.getProperty("com.siemens.IMEI");
if(s == null)
s = System.getProperty("com.sonyericsson.imei");
if(s == null)
s = System.getProperty("IMEI");
String s1 = "";
for(int i = 0; i < s.length(); i++)
{
char c1;
if((c1 = s.charAt(i)) <= '9' && c1 >= '.')
s1 = s1 + s.charAt(i);
}
if(s1.length() > 9)
s1 = s1.substring(s1.length() - 9);
int j;
j = (j = Integer.parseInt(s1.substring(0, s1.length() - 3))) + Integer.parseInt(s1.substring(s1.length() - 3));
s = (s1 = "102359" + String.valueOf(j)).substring(s1.length() - 6);
stringItem.setText(s);
if (textField.getString().trim().length()==6)
s=textField.getString().trim();
int i1 = Integer.parseInt(s.substring(0, 1));
int j1 = Integer.parseInt(s.substring(1, 2));
int k1 = Integer.parseInt(s.substring(2, 3));
int l1 = Integer.parseInt(s.substring(3, 4));
int i2 = Integer.parseInt(s.substring(4, 5));
int j2 = Integer.parseInt(s.substring(5, 6));
i1 += k1 + 3;
j1 += j2 + 2;
k1 += j2 + i2;
l1 += j1 + 5;
i2 += i1 + 1;
j2 += i2 + l1;
i1 %= 10;
j1 %= 10;
k1 %= 10;
l1 %= 10;
i2 %= 10;
j2 %= 10;
stringItem1.setText("" + i1 + j1 + k1 + l1 + i2 + j2);
}//GEN-BEGIN:|7-commandAction|5|7-postCommandAction
}//GEN-END:|7-commandAction|5|7-postCommandAction
// write post-action user code here
}//GEN-BEGIN:|7-commandAction|6|
//</editor-fold>//GEN-END:|7-commandAction|6|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">//GEN-BEGIN:|18-getter|0|18-preInit
/**
* Returns an initiliazed instance of exitCommand component.
* @return the initialized component instance
*/
public Command getExitCommand() {
if (exitCommand == null) {//GEN-END:|18-getter|0|18-preInit
// write pre-init user code here
exitCommand = new Command("Exit", Command.EXIT, 0);//GEN-LINE:|18-getter|1|18-postInit
// write post-init user code here
}//GEN-BEGIN:|18-getter|2|
return exitCommand;
}
//</editor-fold>//GEN-END:|18-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: Main ">//GEN-BEGIN:|14-getter|0|14-preInit
/**
* Returns an initiliazed instance of Main component.
* @return the initialized component instance
*/
public Form getMain() {
if (Main == null) {//GEN-END:|14-getter|0|14-preInit
// write pre-init user code here
Main = new Form("Welcome", new Item[] { getStringItem(), getTextField(), getStringItem1(), getSpacer(), getStringItem2() });//GEN-BEGIN:|14-getter|1|14-postInit
Main.addCommand(getExitCommand());
Main.addCommand(getOkCommand());
Main.setCommandListener(this);//GEN-END:|14-getter|1|14-postInit
// write post-init user code here
}//GEN-BEGIN:|14-getter|2|
return Main;
}
//</editor-fold>//GEN-END:|14-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem ">//GEN-BEGIN:|16-getter|0|16-preInit
/**
* Returns an initiliazed instance of stringItem component.
* @return the initialized component instance
*/
public StringItem getStringItem() {
if (stringItem == null) {//GEN-END:|16-getter|0|16-preInit
// write pre-init user code here
stringItem = new StringItem("This is your mob code:", "000000");//GEN-LINE:|16-getter|1|16-postInit
// write post-init user code here
}//GEN-BEGIN:|16-getter|2|
return stringItem;
}
//</editor-fold>//GEN-END:|16-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand ">//GEN-BEGIN:|21-getter|0|21-preInit
/**
* Returns an initiliazed instance of okCommand component.
* @return the initialized component instance
*/
public Command getOkCommand() {
if (okCommand == null) {//GEN-END:|21-getter|0|21-preInit
// write pre-init user code here
okCommand = new Command("Generate", Command.OK, 0);//GEN-LINE:|21-getter|1|21-postInit
// write post-init user code here
}//GEN-BEGIN:|21-getter|2|
return okCommand;
}
//</editor-fold>//GEN-END:|21-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem1 ">//GEN-BEGIN:|24-getter|0|24-preInit
/**
* Returns an initiliazed instance of stringItem1 component.
* @return the initialized component instance
*/
public StringItem getStringItem1() {
if (stringItem1 == null) {//GEN-END:|24-getter|0|24-preInit
// write pre-init user code here
stringItem1 = new StringItem("Registration code:", "000000");//GEN-LINE:|24-getter|1|24-postInit
// write post-init user code here
}//GEN-BEGIN:|24-getter|2|
return stringItem1;
}
//</editor-fold>//GEN-END:|24-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: helpCommand ">//GEN-BEGIN:|25-getter|0|25-preInit
/**
* Returns an initiliazed instance of helpCommand component.
* @return the initialized component instance
*/
public Command getHelpCommand() {
if (helpCommand == null) {//GEN-END:|25-getter|0|25-preInit
// write pre-init user code here
helpCommand = new Command("Help", Command.HELP, 0);//GEN-LINE:|25-getter|1|25-postInit
// write post-init user code here
}//GEN-BEGIN:|25-getter|2|
return helpCommand;
}
//</editor-fold>//GEN-END:|25-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand1 ">//GEN-BEGIN:|28-getter|0|28-preInit
/**
* Returns an initiliazed instance of okCommand1 component.
* @return the initialized component instance
*/
public Command getOkCommand1() {
if (okCommand1 == null) {//GEN-END:|28-getter|0|28-preInit
// write pre-init user code here
okCommand1 = new Command("Ok", Command.OK, 0);//GEN-LINE:|28-getter|1|28-postInit
// write post-init user code here
}//GEN-BEGIN:|28-getter|2|
return okCommand1;
}
//</editor-fold>//GEN-END:|28-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: spacer ">//GEN-BEGIN:|32-getter|0|32-preInit
/**
* Returns an initiliazed instance of spacer component.
* @return the initialized component instance
*/
public Spacer getSpacer() {
if (spacer == null) {//GEN-END:|32-getter|0|32-preInit
// write pre-init user code here
spacer = new Spacer(16, 1);//GEN-LINE:|32-getter|1|32-postInit
// write post-init user code here
}//GEN-BEGIN:|32-getter|2|
return spacer;
}
//</editor-fold>//GEN-END:|32-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem2 ">//GEN-BEGIN:|33-getter|0|33-preInit
/**
* Returns an initiliazed instance of stringItem2 component.
* @return the initialized component instance
*/
public StringItem getStringItem2() {
if (stringItem2 == null) {//GEN-END:|33-getter|0|33-preInit
// write pre-init user code here
stringItem2 = new StringItem("ABouT:\nKeyGen By Oep=RingZer0", "");//GEN-LINE:|33-getter|1|33-postInit
// write post-init user code here
}//GEN-BEGIN:|33-getter|2|
return stringItem2;
}
//</editor-fold>//GEN-END:|33-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField ">//GEN-BEGIN:|34-getter|0|34-preInit
/**
* Returns an initiliazed instance of textField component.
* @return the initialized component instance
*/
public TextField getTextField() {
if (textField == null) {//GEN-END:|34-getter|0|34-preInit
// write pre-init user code here
textField = new TextField("Enter your mob code:", null, 32, TextField.ANY);//GEN-LINE:|34-getter|1|34-postInit
// write post-init user code here
}//GEN-BEGIN:|34-getter|2|
return textField;
}
//</editor-fold>//GEN-END:|34-getter|2|
/**
* Returns a display instance.
* @return the display instance.
*/
public Display getDisplay () {
return Display.getDisplay(this);
}
/**
* Exits MIDlet.
*/
public void exitMIDlet() {
switchDisplayable (null, null);
destroyApp(true);
notifyDestroyed();
}
/**
* Called when MIDlet is started.
* Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
*/
public void startApp() {
if (midletPaused) {
resumeMIDlet ();
} else {
initialize ();
startMIDlet ();
}
midletPaused = false;
}
/**
* Called when MIDlet is paused.
*/
public void pauseApp() {
midletPaused = true;
}
/**
* Called to signal the MIDlet to terminate.
* @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
*/
public void destroyApp(boolean unconditional) {
}
}