Home  | My Account  |  Membership
WorldDeveloper.org
Forum Details
Topics
Posts
Categories
 
577 member(s)
718,905 hit(s)
14 categories
51 topics
26 messages
0 online
Forums: Code Post
hi there..Actually i want to edit one small mobile application but i have encountered one problem when i run that application in my mobile... i.e.Unknown application. Could u give some possible solutions....thanks in advance..
fakru
2 topic(s)
0 post(s)

June 06, 2011 1:45 PM


// Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: AgeCalc2.java

import java.io.IOException;
import java.io.PrintStream;
import java.util.Calendar;
import java.util.Date;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;

public class AgeCalc2 extends MIDlet
implements CommandListener
{

public AgeCalc2()
{
display = Display.getDisplay(this);
mMainForm = new Form("AgeCalc");
aboutForm = new Form("About Age Calc");
msgBox = new Alert("Warning!", "", null, AlertType.ERROR);
cDate = new Date();
bDate = new Date();
cCal = Calendar.getInstance();
bCal = Calendar.getInstance();
cCal.setTime(cDate);
bCal.setTime(bDate);
currentDate = new DateField("Pinku", 1);// Here i have edited datafiled name as pinku but actually it was current date.
birthDate = new DateField("Birth Date", 1);
currentDate.setDate(cDate);
birthDate.setDate(bDate);
msgBox.setTimeout(-2);
ageField = new StringItem("Age:", null);
mMainForm.append(birthDate);
mMainForm.append(currentDate);
mMainForm.append(ageField);
mMainForm.addCommand(new Command("Exit", 7, 0));
mMainForm.setCommandListener(this);
mMainForm.addCommand(new Command("Calculate", 1, 0));
mMainForm.setCommandListener(this);
mMainForm.addCommand(new Command("About", 1, 0));
mMainForm.setCommandListener(this);
aboutForm.addCommand(new Command("Back", 2, 0));
aboutForm.setCommandListener(this);
try
{
img = Image.createImage("/AgeCalc2.png");
ImageItem imageitem = new ImageItem("", img, 3, "img");
aboutForm.append(imageitem);
}
catch(IOException ioexception)
{
System.out.println("could not create image: " + ioexception);
}
aboutForm.append(new StringItem("Age Calculator 2.0\nCopyright (c) 2005, All rights reserved.\nBy: Abdelbaset Rabayah\nhttp://www.abdelbaset.info\nEnjoy!", null));
}

public void findAge()
{
int i = 0;
int j = 0;
int k = 0;
int l = 0;
int i1 = 0;
int j1 = 0;
cCal.setTime(currentDate.getDate());
i = cCal.get(5);
j = cCal.get(2) + 1;
k = cCal.get(1);
bCal.setTime(birthDate.getDate());
int k1 = bCal.get(5);
int l1 = bCal.get(2) + 1;
int i2 = bCal.get(1);
l = k - i2;
if(l1 > j)
{
l--;
i1 = 12 - Math.abs(j - l1);
} else
{
i1 = j - l1;
}
if(k1 > i)
{
i1--;
switch(j)
{
case 1: // '\001'
case 3: // '\003'
case 5: // '\005'
case 7: // '\007'
case 8: // '\b'
case 10: // '\n'
case 12: // '\f'
j1 = 31 - Math.abs(i - k1);
break;

case 4: // '\004'
case 6: // '\006'
case 9: // '\t'
case 11: // '\013'
j1 = 30 - Math.abs(i - k1);
break;

case 2: // '\002'
j1 = 28 - Math.abs(i - k1);
break;
}
} else
{
j1 = i - k1;
}
String s = "Age: " + l + " years, " + i1 + " months, and " + j1 + " days.";
if(k1 1 || k1 > 31)
{
msgBox.setString("Illegal value!\nPlease check day.");
s = "Age:";
display.setCurrent(msgBox);
}
if(l1 1 || l1 > 12)
{
msgBox.setString("Illegal value!\nPlease check month.");
s = "Age:";
display.setCurrent(msgBox);
}
if(i2 0 || i2 > k)
{
msgBox.setString("Illegal value!\nPlease check year.");
s = "Age:";
display.setCurrent(msgBox);
}
ageField.setLabel(s);
}

public void startApp()
{
display.setCurrent(mMainForm);
}

public void pauseApp()
{
}

public void destroyApp(boolean flag1)
{
}

public void commandAction(Command command, Displayable displayable)
{
String s = command.getLabel();
System.out.println(s);
if(s.equals("Exit"))
notifyDestroyed();
else
if(s.equals("Calculate"))
findAge();
else
if(s.equals("About"))
display.setCurrent(aboutForm);
else
display.setCurrent(mMainForm);
}

private Form mMainForm;
private Form aboutForm;
private DateField currentDate;
private DateField birthDate;
private Command exitCommand;
private Command calcCommand;
private Command aboutCommand;
private Command backCommand;
private Display display;
private StringItem ageField;
private Alert msgBox;
private Image img;
private Calendar cCal;
private Calendar bCal;
private Date cDate;
private Date bDate;
}


©2008 WorldDeveloper.org - PO Box 310575 Miami, FL 33231

WorldDeveloper.org is a managed social network for application developers around the world.