×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    May 2008
    Posts
    68

    way to find if sms connection exist or dead in j2me

    hi,

    1.is there any way to find whether the established sms connection is alive or not ?

    if have any solution pls provide with source.

    2.is there any solution to check whether device battery power is low ?

  2. #2
    Regular Contributor
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100

    Re: way to find if sms connection exist or dead in j2me

    Hi,

    1) Well, There is no Method for the Sms Connection which you could retrieve - isAlive().
    A solution in which you could do is Wrapping your SMS code over Thread or Timer+Tasker(for Scheduling your Sending.

    This is only an example. for sending text message over sms
    Code:
    import java.io.IOException;
    import javax.microedition.io.Connector;
    import javax.wireless.messaging.MessageConnection;
    import javax.wireless.messaging.TextMessage;
    
    /** Sends an SMS message */
    public class SMSender implements Runnable {
      private String smsReceiverPort;
      private String message;
      private String phoneNumber;
    
      public SMSender(String smsReceiverPort) {
        this.smsReceiverPort = smsReceiverPort;
      }
    
      public void run() {
        StringBuffer addr = new StringBuffer(20);
        addr.append("sms://+");
         addr.append(phoneNumber);
        // String address = "sms://+8613641301055";
        String address = addr.toString();
    
        MessageConnection smsconn = null;
        try {
          // Open the message connection.
          smsconn = (MessageConnection) Connector.open(address);
          // Create the message.
          TextMessage txtmessage = (TextMessage) smsconn
              .newMessage(MessageConnection.TEXT_MESSAGE);
          txtmessage.setAddress(address);// !!
          txtmessage.setPayloadText(message);
          smsconn.send(txtmessage);
        } catch (Exception e) {
          e.printStackTrace();
        }
    
        if (smsconn != null) {
          try {
            smsconn.close();
          } catch (IOException ioe) {
            ioe.printStackTrace();
          }
        }
      }
    
      public void send(String message, String phoneNumber) {
        this.message = message;
        this.phoneNumber = phoneNumber;
        Thread t = new Thread(this);
        t.start();
      }
    
    }
    2) impossible at the moment.

  3. #3
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: way to find if sms connection exist or dead in j2me

    Hello prashantpersistent,

    2.is there any solution to check whether device battery power is low ?
    Currently this is possible only with S60 3rd Edition, Feature Pack 2 devices by using this system property string:

    "com.nokia.mid.batterylevel"

    Using System.getProperty("com.nokia.mid.batterylevel") returns the battery charge level of device. The property value is the actual battery level in percentage.

    Source (under 'S60 3rd Edition, FP2 system properties'): http://wiki.forum.nokia.com/index.ph...tem_properties

    Regards,
    r2j7
    [URL="http://library.forum.nokia.com/java"][B] >>> Java Developer's Library <<<[/B][/URL]
    [URL="https://www.developer.nokia.com/Resources/Support/Technical_support.xhtml"] [B]>>> Technical Support for Java ME development <<<[/B][/URL]
    [URL="https://publish.ovi.com/info/"][B]>>> Nokia Publish: reach millions of Nokia users worldwide through Nokia Store <<<[/B][/URL]

Similar Threads

  1. Listening to SMS sent without any port number - in J2ME
    By ullas.kris in forum General Messaging
    Replies: 3
    Last Post: 2010-01-04, 09:57
  2. Receiving SMS by J2ME Midlet on 3410
    By mlamb in forum Mobile Java General
    Replies: 6
    Last Post: 2009-03-24, 13:13
  3. Send binary SMS to port like in J2ME
    By Robert111 in forum Symbian
    Replies: 22
    Last Post: 2008-11-01, 20:15
  4. SMS Port number of device for receiving SMS using J2ME
    By Huddedar in forum General Messaging
    Replies: 1
    Last Post: 2007-06-22, 18:37
  5. 21 errors in j2me , help in soving them
    By abhishek_1211 in forum General Messaging
    Replies: 0
    Last Post: 2006-04-01, 09:04

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×