473,671 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem in capturing incoming message

49 New Member
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:


Expand|Select|Wrap|Line Numbers
  1.  
  2. import javax.microedition.midlet.*;
  3. import javax.microedition.lcdui.*;
  4. import javax.microedition.io.*;
  5. import javax.wireless.messaging.*;
  6. import java.io.*;
  7.  
  8. import java.util.*;
  9.  
  10.  
  11. public class MessageReceive extends MIDlet implements CommandListener, MessageListener 
  12. {
  13.  
  14.  
  15. private Command exitCommand; 
  16.  
  17. private Command getMsgCommand;
  18.  
  19.  
  20. private Display display;
  21.  
  22. Form displayForm;
  23. public static String msgReceived ;
  24. Thread Recivethread;
  25.  
  26. MessageConnection serverConn;
  27.  
  28.  
  29.  
  30.  
  31.  
  32. public MessageReceive () {
  33. display = Display.getDisplay(this);
  34. exitCommand = 
  35. new Command("Exit", Command.SCREEN, 1);
  36. getMsgCommand = 
  37. new Command("Get", Command.SCREEN, 1);
  38.  
  39.  
  40. }
  41.  
  42.  
  43. public void startApp() {
  44. displayForm = new Form("Get Message");
  45.  
  46. displayForm.addCommand(exitCommand);
  47. displayForm.addCommand(getMsgCommand);
  48.  
  49. displayForm.setCommandListener(this);
  50.  
  51. display.setCurrent(displayForm);
  52.  
  53. try
  54. {
  55. Alert rrrecAlert = new Alert("","Mesage connection open",null, AlertType.INFO);
  56. rrrecAlert.setTimeout(Alert.FOREVER);
  57. display.setCurrent(rrrecAlert, displayForm);
  58. serverConn = (MessageConnection)Connector.open("sms://:5000",Connector.READ);
  59.  
  60. serverConn.setMessageListener(this);
  61. Alert ecAlert = new Alert("","Mesage Listener.....",null, AlertType.INFO);
  62. ecAlert.setTimeout(Alert.FOREVER);
  63. display.setCurrent(ecAlert, displayForm);
  64. Recivethread = new Thread(new CatchRecMsg());
  65. Recivethread.start();
  66.  
  67. }
  68. catch (IOException ioExc)
  69. {
  70. Alert ecAlert = new Alert("","Server connection could not be obtained",null, AlertType.INFO);
  71. ecAlert.setTimeout(Alert.FOREVER);
  72. display.setCurrent(ecAlert, displayForm);
  73.  
  74.  
  75. }
  76.  
  77.  
  78. public synchronized void notifyIncomingMessage(MessageConnection conn) {
  79.  
  80. Alert ecAlert = new Alert("","Mesage Incoming Listener.....",null, AlertType.INFO);
  81. ecAlert.setTimeout(Alert.FOREVER);
  82. display.setCurrent(ecAlert, displayForm);
  83. if (conn == serverConn) {
  84.  
  85. Recivethread = new Thread(new CatchRecMsg());
  86. Recivethread.start();
  87. }
  88. else{
  89. Alert eAlert = new Alert("","Mesage conn not equals.....",null, AlertType.INFO);
  90. eAlert.setTimeout(Alert.FOREVER);
  91. display.setCurrent(eAlert, displayForm);
  92.  
  93. }
  94.  
  95. }
  96.  
  97. public class CatchRecMsg implements Runnable
  98. {
  99. public void run() {
  100. try{
  101.  
  102. Alert recAlert = new Alert("","This is getting",null, AlertType.INFO);
  103. recAlert.setTimeout(Alert.FOREVER);
  104. display.setCurrent(recAlert, displayForm);
  105.  
  106. try {
  107. System.out.println("In the catchReceive ");
  108.  
  109. Message msg = serverConn.receive();
  110. System.out.println("Out the the catchReceive ");
  111. if (msg instanceof TextMessage) {
  112. TextMessage tmsg = (TextMessage)msg;
  113. msgReceived = tmsg.getPayloadText();
  114. recAlert = new Alert("","We got the masg Text : "+msgReceived,null, AlertType.INFO);
  115. recAlert.setTimeout(Alert.FOREVER);
  116. display.setCurrent(recAlert, displayForm);
  117. displayForm.append(msgReceived);
  118. display.setCurrent(displayForm);
  119.  
  120. }
  121. else 
  122.  
  123. if (msg instanceof BinaryMessage) {
  124. BinaryMessage bmsg = (BinaryMessage)msg;
  125. byte[] data = bmsg.getPayloadData();
  126.  
  127. msgReceived = data.toString();
  128. displayForm.append(msgReceived);
  129. display.setCurrent(displayForm);
  130.  
  131. recAlert = new Alert("","We got the masg Binary : " +msgReceived,null, AlertType.INFO);
  132. recAlert.setTimeout(Alert.FOREVER);
  133. display.setCurrent(recAlert, displayForm);
  134. }
  135.  
  136. else
  137. {
  138. recAlert = new Alert("","Msg getting is nothing"+msg,null, AlertType.INFO);
  139. recAlert.setTimeout(Alert.FOREVER);
  140. display.setCurrent(recAlert, displayForm);
  141. }
  142. }
  143. catch (Exception e) {
  144. recAlert = new Alert("","Error occurs in receive()"+e,null, AlertType.INFO);
  145. recAlert.setTimeout(Alert.FOREVER);
  146. display.setCurrent(recAlert, displayForm);
  147. }
  148.  
  149. } catch (Exception e) {
  150. Alert recAlert = new Alert("","I got error here",null, AlertType.INFO);
  151. recAlert.setTimeout(Alert.FOREVER);
  152. display.setCurrent(recAlert, displayForm);
  153. }
  154. }
  155.  
  156.  
  157.  
  158.  
  159. public void pauseApp()
  160. { }
  161.  
  162.  
  163.  
  164. public void destroyApp(boolean unconditional) { 
  165.  
  166.  
  167.  
  168. }
  169.  
  170.  
  171. public void commandAction(
  172. Command c, Displayable s) {
  173. if (c == exitCommand) {
  174. destroyApp(false);
  175. notifyDestroyed();
  176. }
  177.  
  178. if (c == getMsgCommand) {
  179. try
  180. {
  181.  
  182. displayForm.append(msgReceived);
  183.  
  184. display.setCurrent(displayForm);
  185. Alert ecAlert = new Alert("","nothing there .....",null, AlertType.INFO);
  186. ecAlert.setTimeout(Alert.FOREVER);
  187. display.setCurrent(ecAlert, displayForm);
  188.  
  189. }
  190. catch (Exception exc)
  191. {
  192. exc.printStackTrace();
  193. }
  194.  
  195.  
  196. }
  197. }
  198.  
  199.  
  200.  
  201. }
  202.  


regards
LTCCTL
Dec 24 '08 #1
0 1897

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1716
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.
5
3819
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'
5
1399
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
5
6398
by: Lasse Edsvik | last post by:
Hello I have this: public SqlParameter GetParameter(string sqlparam) { SqlParameter param = cmd.Parameters.Add(sqlparam);
14
2533
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
4
3063
by: tma | last post by:
How does one capture the IP address of an incoming connection to an ASPX page?
9
1768
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
2
10524
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 = ""
4
10156
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
0
8472
marktang
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...
0
8390
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,...
0
8819
jinu1996
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...
1
8596
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,...
0
8667
tracyyun
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...
0
7428
agi2029
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...
0
5690
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();...
0
4221
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...
2
1801
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.