j2me application to know cell id

আমাদের ফাইনাল ইয়ার প্রজেক্ট LBS এর একটি অংশ হিসেবে j2me base app develop করতে হবে…যার কাজ হবে user থেকে demand নেয়া,user position(GPS+Cell Id) নিয়ে server এ পাঠানো এবং server থেকে পাওয়া information (maps+position) user interface এর মাধ্যমে show করানো…প্রথম অংশ হিসেব user cell id বের করাটা tough ছিলো (coz আমরা j2me তে newbie )।যাইহোক অনেক সংগ্রামের পর পারলাম 😀

only run on S60 FP2(minimum)

code here:


/*
* To change this template, choose Tools | Templates<
* and open the template in the editor.
*/
//this code will retrive the cell id from S series set
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class CellIDMIDlet extends MIDlet implements CommandListener {
private Form form;
private Command exitCommand;
private String S40_cell_id;   // Series 40 cell id property
private String S60_cell_id;   // S60 cell id property
public void startApp() {
form = new Form("Getting Cell ID");
S40_cell_id = System.getProperty("Cell-ID");
S60_cell_id = System.getProperty("com.nokia.mid.cellid");
form.append("Series 40 devices: " + S40_cell_id + "\n");
form.append("S60 devices: " + S60_cell_id);
exitCommand = new Command("Exit", Command.EXIT, 1);
form.setCommandListener(this);
form.addCommand(exitCommand);
Display.getDisplay(this).setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
if (c == exitCommand) this.notifyDestroyed();
}
}

আমি আমার  Nokia E66 সেটে test করেছি Dhaka-Chittagong highway তে। that worked well:)

Advertisements

j2me তে হাতে খড়ি

Different কিছু শিখবো দেখেই আমরা কিছুটা different একটা প্রজেক্ট সিলেক্ট করেছিলাম(Location Based Services).প্রজেক্টের মুল concept টা এরকম যে location based advertising,emergency services etc using a mobile application+there will be also a web interface for the desktop clients.আমরা এ ব্যাপারে রনি ভাইএর সাহায্য নেই,

উনি আমাদেরকে প্রথম যে task দেন তা হল : UI design.
প্রথম প্রথম একটু ঝামেলা লাগলেও এখন দারুন মজা পাইতেছি 🙂
আমার প্রথম j2me UI code ছিলো এরকমঃ

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author mushfiq date:16-03-2010
*/
public class design extends MIDlet implements CommandListener{
private Display display;
private TextBox textbox1;
private Form form;
private Form form1;
private ChoiceGroup subject;
private int subjectindex;
private Command backcmd;
private Command formcmd;
private Command chckcmd;
private Command textcmd;
public void startApp()
{
display = Display.getDisplay(this);
formcmd = new Command("Form", Command.SCREEN, 0);
chckcmd = new Command("Check Box", Command.SCREEN, 1);
textbox1 = new TextBox("Text Box","Department of CSTE ", 80, 0);
backcmd = new Command("Quit", Command.SCREEN, 3);
textcmd = new Command("Text Box",Command.SCREEN, 2);
textbox1.addCommand(backcmd);
textbox1.addCommand(formcmd);//
textbox1.addCommand(chckcmd);
textbox1.setCommandListener(this);
// display.setCurrent(textbox1);

StringItem msg[] = new StringItem[2];
msg[0] = new StringItem(" Mushfiq","CSTE 2005-2006");
msg[1] = new StringItem("Rimon","Uttara");
form = new Form("Text Form 1", msg);
form.addCommand(backcmd);
form.addCommand(chckcmd);
form.addCommand(textcmd);
// form.addCommand(textbox1);
form.setCommandListener(this);
form1 = new Form("Check Box form");
form1.addCommand(backcmd);
form1.addCommand(textcmd);
form1.addCommand(formcmd);
form1.setCommandListener(this);

subject = new ChoiceGroup("Select your Department",Choice.MULTIPLE); //to use it as radio button have to use EXCLUSIVE
subject.append("CSTE",null);
subject.append("Pharmacy",null);
subject.append("ACCE",null);
subject.append("Microbiology",null);
subject.append("FIMS",null);
subjectindex = form1.append(subject);

display.setCurrent(textbox1);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c,Displayable displayable)
{
if(c == backcmd)
{
destroyApp(false);
notifyDestroyed();
}

else if (c == chckcmd)
{
display.setCurrent(form1);
}
else if (c == textcmd)
{
display.setCurrent(textbox1);
}
else if (c == formcmd)
{
display.setCurrent(form);
}
}
}


এই কোড টা run করলে দেখা যাবে text box,form,menu,check box,radio button.