salut tout le monde mon projet consiste a envoyé et recevoir des SMS entre un PC et un portable a travers un bluetooth (port COM4)
voila mon code pour envoyé un message avec API JSMSenjine
mais il me donne une erreur dans une methode
"CService" not be resolved a type
"COutgoingMessage" not be resolved a type
j'ai importer le JSMSenjine.jar dans mon projet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
import org.jsmsengine.*;
class SendMessage
{
public static void main(String[] args)
{
int status;
// Create jSMSEngine service.
CService srv = new CService("com4", 9600);
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("+919830645175", "Ripon");
// 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);
}
} |
Partager