You Are Here:

Community: Developer Discussion Boards

#1 Old way to find if sms connection exist or dead in j2me - 2008-07-31, 08:46

Join Date: May 2008
Posts: 68
prashantpersistent
Offline
Regular Contributor
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 ?
Reply With Quote

#2 Old Re: way to find if sms connection exist or dead in j2me - 2008-07-31, 11:11

Join Date: Jun 2008
Posts: 100
Location: Tel-Aviv,Israel
Send a message via MSN to ypele Send a message via Skype™ to ypele
ypele
Offline
Regular Contributor
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.
Reply With Quote

#3 Old Re: way to find if sms connection exist or dead in j2me - 2008-08-01, 14:40

Join Date: Aug 2007
Posts: 774
r2j7's Avatar
r2j7
Offline
Forum Nokia Expert
Hello prashantpersistent,

Quote:
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
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Receiving SMS by J2ME Midlet on 3410 mlamb Mobile Java General 6 2009-03-24 14:13
Send binary SMS to port like in J2ME Robert111 Python 22 2008-11-01 21:15
Listening to SMS sent without any port number - in J2ME ullas.kris General Messaging 2 2007-08-14 22:45
SMS Port number of device for receiving SMS using J2ME Huddedar General Messaging 1 2007-06-22 19:37
21 errors in j2me , help in soving them abhishek_1211 General Messaging 0 2006-04-01 10:04

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia