| Reply | « Previous Thread | Next Thread » |
|
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 ? |
| prashantpersistent |
| View Public Profile |
| Find all posts by prashantpersistent |
|
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();
}
}
|
|
Hello prashantpersistent,
Quote:
"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 | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| 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 |