?? sendmessage.java
字號(hào):
import org.jsmsengine.*;class SendMessage{ public static void main(String[] args) { int status; // Create jSMSEngine service. CService srv = new CService("com6", 115200); System.out.println(); System.out.println("SendMessage(): sample application."); System.out.println(" Using " + srv._name + " " + srv._version); System.out.println(); try { // Initialize service. srv.initialize(); // Set the cache directory. srv.setCacheDir(".\\"); // Set the phonebook. // srv.setPhoneBook("../misc/phonebook.xml"); // Connect to GSM device. status = srv.connect(); // Did we connect ok? if (status == CService.ERR_OK) { // Set the operation mode to PDU - default is ASCII. srv.setOperationMode(CService.MODE_PDU); // Set the SMSC number (set to default). srv.setSmscNumber(""); // Print out GSM device info... System.out.println("Mobile Device Information: "); System.out.println(" Manufacturer : " + srv.getDeviceInfo().getManufacturer()); System.out.println(" Model : " + srv.getDeviceInfo().getModel()); System.out.println(" Serial No : " + srv.getDeviceInfo().getSerialNo()); System.out.println(" IMSI : " + srv.getDeviceInfo().getImsi()); System.out.println(" S/W Version : " + srv.getDeviceInfo().getSwVersion()); System.out.println(" Battery Level : " + srv.getDeviceInfo().getBatteryLevel() + "%"); System.out.println(" Signal Level : " + srv.getDeviceInfo().getSignalLevel() + "%"); // Create a COutgoingMessage object and dispatch it. // *** Please update the phone number with one of your choice *** COutgoingMessage msg = new COutgoingMessage("+6596777992", "Message from jSMSEngine API."); // Character set is 7bit by default - lets make it UNICODE :) // We can do this, because we are in PDU mode (look at line 63). When in ASCII mode, // this does not make ANY difference... msg.setMessageEncoding(CMessage.MESSAGE_ENCODING_UNICODE); if (srv.sendMessage(msg) == CService.ERR_OK) System.out.println("Message Sent!"); else System.out.println("Message Failed!"); // Disconnect from GSM device. srv.disconnect(); } else System.out.println("Connection to mobile failed, error: " + status); } catch (Exception e) { e.printStackTrace(); } System.exit(0); }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -