hi all,
I have an application to send and recieve an SMS but my application is not catching the incoming message.
can anyone tell what's wrong with the following code: -
-
import javax.microedition.midlet.*;
-
import javax.microedition.lcdui.*;
-
import javax.microedition.io.*;
-
import javax.wireless.messaging.*;
-
import java.io.*;
-
-
import java.util.*;
-
-
-
public class MessageReceive extends MIDlet implements CommandListener, MessageListener
-
{
-
-
-
private Command exitCommand;
-
-
private Command getMsgCommand;
-
-
-
private Display display;
-
-
Form displayForm;
-
public static String msgReceived ;
-
Thread Recivethread;
-
-
MessageConnection serverConn;
-
-
-
-
-
-
public MessageReceive () {
-
display = Display.getDisplay(this);
-
exitCommand =
-
new Command("Exit", Command.SCREEN, 1);
-
getMsgCommand =
-
new Command("Get", Command.SCREEN, 1);
-
-
-
}
-
-
-
public void startApp() {
-
displayForm = new Form("Get Message");
-
-
displayForm.addCommand(exitCommand);
-
displayForm.addCommand(getMsgCommand);
-
-
displayForm.setCommandListener(this);
-
-
display.setCurrent(displayForm);
-
-
try
-
{
-
Alert rrrecAlert = new Alert("","Mesage connection open",null, AlertType.INFO);
-
rrrecAlert.setTimeout(Alert.FOREVER);
-
display.setCurrent(rrrecAlert, displayForm);
-
serverConn = (MessageConnection)Connector.open("sms://:5000",Connector.READ);
-
-
serverConn.setMessageListener(this);
-
Alert ecAlert = new Alert("","Mesage Listener.....",null, AlertType.INFO);
-
ecAlert.setTimeout(Alert.FOREVER);
-
display.setCurrent(ecAlert, displayForm);
-
Recivethread = new Thread(new CatchRecMsg());
-
Recivethread.start();
-
-
}
-
catch (IOException ioExc)
-
{
-
Alert ecAlert = new Alert("","Server connection could not be obtained",null, AlertType.INFO);
-
ecAlert.setTimeout(Alert.FOREVER);
-
display.setCurrent(ecAlert, displayForm);
-
}
-
-
-
}
-
-
-
public synchronized void notifyIncomingMessage(MessageConnection conn) {
-
-
Alert ecAlert = new Alert("","Mesage Incoming Listener.....",null, AlertType.INFO);
-
ecAlert.setTimeout(Alert.FOREVER);
-
display.setCurrent(ecAlert, displayForm);
-
if (conn == serverConn) {
-
-
Recivethread = new Thread(new CatchRecMsg());
-
Recivethread.start();
-
}
-
else{
-
Alert eAlert = new Alert("","Mesage conn not equals.....",null, AlertType.INFO);
-
eAlert.setTimeout(Alert.FOREVER);
-
display.setCurrent(eAlert, displayForm);
-
-
}
-
-
}
-
-
public class CatchRecMsg implements Runnable
-
{
-
public void run() {
-
try{
-
-
Alert recAlert = new Alert("","This is getting",null, AlertType.INFO);
-
recAlert.setTimeout(Alert.FOREVER);
-
display.setCurrent(recAlert, displayForm);
-
-
try {
-
System.out.println("In the catchReceive ");
-
-
Message msg = serverConn.receive();
-
System.out.println("Out the the catchReceive ");
-
if (msg instanceof TextMessage) {
-
TextMessage tmsg = (TextMessage)msg;
-
msgReceived = tmsg.getPayloadText();
-
recAlert = new Alert("","We got the masg Text : "+msgReceived,null, AlertType.INFO);
-
recAlert.setTimeout(Alert.FOREVER);
-
display.setCurrent(recAlert, displayForm);
-
displayForm.append(msgReceived);
-
display.setCurrent(displayForm);
-
-
}
-
else
-
-
if (msg instanceof BinaryMessage) {
-
BinaryMessage bmsg = (BinaryMessage)msg;
-
byte[] data = bmsg.getPayloadData();
-
-
msgReceived = data.toString();
-
displayForm.append(msgReceived);
-
display.setCurrent(displayForm);
-
-
recAlert = new Alert("","We got the masg Binary : " +msgReceived,null, AlertType.INFO);
-
recAlert.setTimeout(Alert.FOREVER);
-
display.setCurrent(recAlert, displayForm);
-
}
-
-
else
-
{
-
recAlert = new Alert("","Msg getting is nothing"+msg,null, AlertType.INFO);
-
recAlert.setTimeout(Alert.FOREVER);
-
display.setCurrent(recAlert, displayForm);
-
}
-
}
-
catch (Exception e) {
-
recAlert = new Alert("","Error occurs in receive()"+e,null, AlertType.INFO);
-
recAlert.setTimeout(Alert.FOREVER);
-
display.setCurrent(recAlert, displayForm);
-
}
-
-
} catch (Exception e) {
-
Alert recAlert = new Alert("","I got error here",null, AlertType.INFO);
-
recAlert.setTimeout(Alert.FOREVER);
-
display.setCurrent(recAlert, displayForm);
-
}
-
}
-
}
-
-
-
-
-
public void pauseApp()
-
{ }
-
-
-
-
public void destroyApp(boolean unconditional) {
-
-
-
-
}
-
-
-
public void commandAction(
-
Command c, Displayable s) {
-
if (c == exitCommand) {
-
destroyApp(false);
-
notifyDestroyed();
-
}
-
-
if (c == getMsgCommand) {
-
try
-
{
-
-
displayForm.append(msgReceived);
-
-
display.setCurrent(displayForm);
-
Alert ecAlert = new Alert("","nothing there .....",null, AlertType.INFO);
-
ecAlert.setTimeout(Alert.FOREVER);
-
display.setCurrent(ecAlert, displayForm);
-
-
}
-
catch (Exception exc)
-
{
-
exc.printStackTrace();
-
}
-
-
-
}
-
}
-
-
-
-
}
-
regards
LTCCTL
0 1897 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dan |
last post by:
A Newbie needs help!
Is it possible, in PHP, to capture the resulting HTML of a submitted
form returning from a server and incorporate that HTML into say a
table, or some predefined layout?
I am trying to incorporate the resulting HTML into a layout I have
created in order to keep the look & feel of my site consistent, but
the resulting page is a plain "cheesy" page.
|
by: Andrew Dixon |
last post by:
Hi Everyone.
Ok I have a problem getting the following regex to work in Java.
<script*>(.|\r|\n)+?</script>
It works fine in EditPad Pro but in Java it causes the following error
message when ran:-
'Exception in thread "main" java.lang.StackOverflowError'
|
by: Benny |
last post by:
Hi,
Is there a script/compoenent which can capture Faxes and store that in a DB
using a unique ID?
Any help will be greatly appriciated.
Thanks,
Benny
|
by: Lasse Edsvik |
last post by:
Hello
I have this:
public SqlParameter GetParameter(string sqlparam)
{
SqlParameter param = cmd.Parameters.Add(sqlparam);
|
by: Brent Burkart |
last post by:
I am trying to capture the Windows Authenticated username, but I want to be
able to capture the login name that exists in IIS, not Windows. In order to
enter my company's intranet through the internet, they have to login. I want
to be able to capture that login versus their Windows login because I need
to know who they are from any computer rather than only their computer. Any
ideas?
Thanks
| |
by: tma |
last post by:
How does one capture the IP address of an incoming connection to an ASPX
page?
|
by: google_groups3 |
last post by:
Hi all.
This is a bit of a long shot i think but right now i am all out of
ideas, so any help is greatly appreciated!
I have an app that sends information on a specific port. However, te
port is blocked on the firewall so the app won't connect. Changing the
firewall config is not an option, nor is reconfiguring the app.
So, my question is this. Is there a way to develop an app that
|
by: Jan |
last post by:
Hello there,
I've got a strange problem using the readline method in vb2005 for
reading the serial port.
If I use the readchar method I can receive one character from
serialport. This is the code I use:
Function ReceiveSerialData() As String
' Receive strings from a serial port.
Dim returnStr As String = ""
|
by: sracherla |
last post by:
I am trying to write a simple windows service that accepts an incoming
request; receives a string input and sends a string output. I need this
connection to stay alive until the client closes it.
Also, I need the service to accept multiple incoming requests.
Here is the code:
public void Listen()
{
#region Commented Code
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |