this is my code in MIDlet Class:
PHP Code:
public class MIDletName extends MIDlet implements MessageListener{
private MessageConnection notifyCon;
public Constructor()
{
}
public void pauseApp()
{
notifyPaused();
}
public void destroyApp(boolean unconditional)
{
try
{
if(notifyCon != null)
{
this.notifyCon.setMessageListener(null);
this.notifyCon.close();
}
//return;
}
catch (IOException ioex)
{
}
finally
{
notifyCon = null;
}
System.gc();
notifyDestroyed();
}
public void notifyIncomingMessage(/*final */MessageConnection MCon)
{
if(MCon == notifyCon)
{
isNotify = true;
new PortListener(this);
}
}
public void PortListener()
{
try
{
if(notifyCon == null)
(notifyCon = (MessageConnection)Connector.open("sms://:16177")).setMessageListener(this);
return;
}
catch(IOException e)
{
}
}
public MessageConnection outNotifyCon()
{
return this.notifyCon;
}
and this is PortListener class:
PHP Code:
public final class PortListener implements Runnable
{
private Thread trd = null;
private MessageConnection notifyCon;
private static MIDletName middd= null;
public PortListener(MIDletName midparam)
{
middd= midparam;
this.notifyCon = midparam.outNotifyCon();
try
{
if(trd == null)
{
trd = new Thread(this);
trd.start();
}
}
catch(Error er)
{}
MIDletName.isNotify = false;//isNotify is static,so access direct to it.otherwise,warning
public void messageReceivedHandler()
{
String receivedMessage = "";
try
{
Message RealCon;
if((RealCon = notifyCon.receive()) != null)
{
if ((RealCon instanceof TextMessage))
{
receivedMessage = ((TextMessage)RealCon).getPayloadText();
}
...
}
public void run()
{
try
{
synchronized(middd)
{
messageReceivedHandler();
}
}
finally
{
this.trd = null;
}
}
there is no problem in java based mobiles.i have problem in WindowsMobiles
i test this JAR in HTC Touch2 t3333(windows moblie 6.5) & HTC Cruise ( ? ).
with Esmertec Jbed 20090506.2.1 by Aqrab MIDletManager.
but i receive messages in inbox(not App).
by the way,in some day,i change part of code,:
PHP Code:
public void pauseApp()
{
notifyPaused();
}
to this:
PHP Code:
public void pauseApp()
{
notifyIncomingMessage(notifyCon)
notifyPaused();
}
and after that,i receive anyMessage,form Any Senders in my App!
i unistall it,and after some days,i install it again,but its not work!!!!
i test these ways to install MIDlet managers:
1-bluetooth CAB file
2-trasnfer CAb to mobile by ActiveSync
but there is no different!
how can i receive messages in my app,in WindowsMobile too?