F
focode
dear every one , i am in critical state , i had to write a application
that can send and receive sms in the same application i am able to
send the sms ( got the java file from the book ) i ahve written an
another application to recive the sms in the same application but
program is not executing , it says that their is some excetion in
startApp fuction , my boss needs it uergently , iahve trusted this
group since my college days and i have laways got the solution to my
problem kindly help me out
here the source code i have written to recive sms in application ,
first i have send the sms "hello" to my mobile the i want to recive it
on the same
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.wireless.messaging.*;
import javax.microedition.io.*;
public class main extends MIDlet implements CommandListener,Runnable {
Sender give;
String mPort="50000";
String msgReceived = null;
private MessageConnection conn = null;
private boolean mEndNow = false;
Thread reciver = null;
Form mForm,reciveForm;
Command ok;
Command Exit;
public void startApp() {
mForm = new Form( "Hello");
mForm.append("hello virtu");
ok = new Command("ok",Command.OK,0);
Exit = new Command("Exit",Command.EXIT,0);
mForm.addCommand(ok);
mForm.addCommand(Exit);
mForm.setCommandListener(this);
Display mDisplay = null;
mDisplay.getCurrent();
mDisplay.setCurrent(mForm);
// give.sendMsg("9990753070","5000" ,"hello" );
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c , Displayable d)
{
if (c == ok)
{
give.sendMsg("9990753070","5000" ,"hello" );
reciver.start();
}
}
public void run()
{
Message msg = null;
String msgReceived = null;
conn=null;
mEndNow = false ;
/** Check for sms connection **/
try{
conn = (MessageConnection) Connector.open("sms://:" +
mPort);
msg = conn.receive();
while(msg !=null)
{
if(msg instanceof TextMessage)
{
msgReceived = ((TextMessage)msg).getPayloadText
();
Display vDisplay = null;
reciveForm = new Form (" msg Arrived");
reciveForm.append(msgReceived);
vDisplay.getCurrent();
vDisplay.setCurrent(mForm);
}
}
}
catch(Exception e)
{
}
}
}
relpy me as soon as possible
that can send and receive sms in the same application i am able to
send the sms ( got the java file from the book ) i ahve written an
another application to recive the sms in the same application but
program is not executing , it says that their is some excetion in
startApp fuction , my boss needs it uergently , iahve trusted this
group since my college days and i have laways got the solution to my
problem kindly help me out
here the source code i have written to recive sms in application ,
first i have send the sms "hello" to my mobile the i want to recive it
on the same
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.wireless.messaging.*;
import javax.microedition.io.*;
public class main extends MIDlet implements CommandListener,Runnable {
Sender give;
String mPort="50000";
String msgReceived = null;
private MessageConnection conn = null;
private boolean mEndNow = false;
Thread reciver = null;
Form mForm,reciveForm;
Command ok;
Command Exit;
public void startApp() {
mForm = new Form( "Hello");
mForm.append("hello virtu");
ok = new Command("ok",Command.OK,0);
Exit = new Command("Exit",Command.EXIT,0);
mForm.addCommand(ok);
mForm.addCommand(Exit);
mForm.setCommandListener(this);
Display mDisplay = null;
mDisplay.getCurrent();
mDisplay.setCurrent(mForm);
// give.sendMsg("9990753070","5000" ,"hello" );
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c , Displayable d)
{
if (c == ok)
{
give.sendMsg("9990753070","5000" ,"hello" );
reciver.start();
}
}
public void run()
{
Message msg = null;
String msgReceived = null;
conn=null;
mEndNow = false ;
/** Check for sms connection **/
try{
conn = (MessageConnection) Connector.open("sms://:" +
mPort);
msg = conn.receive();
while(msg !=null)
{
if(msg instanceof TextMessage)
{
msgReceived = ((TextMessage)msg).getPayloadText
();
Display vDisplay = null;
reciveForm = new Form (" msg Arrived");
reciveForm.append(msgReceived);
vDisplay.getCurrent();
vDisplay.setCurrent(mForm);
}
}
}
catch(Exception e)
{
}
}
}
relpy me as soon as possible