How to use Java language to control SMS devices to implement SMS send and receive?

xiaoxiao2021-03-06  59

Jindi Java version of the secondary development package calling documentation:

Description: This control is only available for Windows platform. If you need Linux platform control, please contact our Sales Department.

First, JINDI JAVA control installation

1. Confirm whether you have a JDK installed before installing the JINDI JAVA control. If you haven't installed JDK yet, I suggest you download and install JDK1.4.

2, let us provide you Sendsms.jar copy to directory

3, provide us with Sendsms.exe, JindismScontrol.ocx, and MSComm32.ocx setings.ini copied to the Windows system System32 directory, and change the setings.ini file, as follows:

----------------------------------- ----------------

| Settings.ini file |

----------------------------------- ----------------

| 1 (In the first line, enter you using the COM port) |

| 8613800100500 (enter SMS center number in the first line) |

| D: /jdk1.4/jre (enter the JDK path in the third line) |

----------------------------------- ----------------

Second, the calling method and routine of JINDI JAVA control

1. Send a text message, please call the SMS Class SendMSG method

Static Boolean Sendmsg (String Msg, String Phone)

MSG you want to send text message

Phone recipient number

example:

Import cn.com.chundi.sendsms. *;

Public class sendmsg {

Public static void main (string args []) {

String Tophone = "13331012788";

SMS SMS1 = New SMS ();

IF (args.length> = 1)

{

Tophone = args [0];

}

Boolean Sendsucc = SMS1.sendmsg ("Hello, Test!", Tophone;

IF (sendSUCC) {

System.out.println ("Send Successful ..............");

} else {

System.out.println ("Send Failure ........");

}

}

}

2, read text messages, please call the ReadMSG method of SMS Class

Read ReadMsg (String Index)

Read SMS in the INDEX location in the SIM card

The location of the SMS in the Index SIM card (starting from 1, the capacity in the general SIM is 15-25)

Returns the READ class object (with the description of the read object)

ArrayList Readmsg (String Beginno, String Endno)

Read SMS in the SIM card in the SIM card to the endno location

Beginno reads the start of SMS in the SIM card

Endno reads the termination location of SMS in the SIM card

Returns the ArrayList class object (converted to the Read object):

Import cn.com.chundi.sendsms. *;

Import java.util. *;

Public class readmsg {

Public static void main (string args []) {

String index = NULL;

String begin = null;

String end = NULL;

SMS SMS1 = New SMS ();

IF (args.lendhe> 1) {

Begin = args [0];

End = args [1];

System.out.println ("IN" Begin "strips in SIM to the" end "text message .............");

ArrayList Listmsg = SMS1.ReadMsg (Begin, End);

IF (Listmsg == Null) {

System.out.println ("Reading Action Failed!");

}

Else {

INT TOTAL = Listmsg.size ();

For (int i = 0; i

Read msg = (read) Listmsg.get (i);

IF ((msg! = null) && (msg.isempty () == false)) {

System.out.println ("No. MSG.Getno () " in SIM is as follows: ");

System.out.println ("From:" msg.getoa ());

System.out.println ("Time:" Msg.getTimeStamp ());

System.out.println ("Content:" msg.getmsg ());

}

Else {

System.out.println ("No. msg.getno () " No SMS "in SIM);

}

}

}

}

Else {

IF (args.length> 0) {

INDEX = args [0];

System.out.println ("I am reading the" Index "text message in SIM ............................ ....... ");

Read msg = SMS1.ReadMSG (INDEX);

IF ((msg! = null) && (msg.isempty () == false)) {

System.out.println ("From:" msg.getoa ());

System.out.println ("Time:" Msg.getTimeStamp ());

System.out.println ("Content:" msg.getmsg ());

}

Else {

System.out.println ("No. INDEX " Location in SIM ");

}

}

}

}

}

3. Delete SMS Please call the delete method delete deletemsg (String Index)

Delete SMS in the INDEX location in the SIM card

The location of the SMS in the Index SIM card (starting from 1, the capacity in the general SIM is 15-25)

Return to the delete class object (with the description of the Delete object)

ArrayList Deletemsg (String Beginno, String Endno)

Delete SMS in the SIM card in the SIM card to endno location

Beginno Delete the start of SMS in the SIM card

Endno Delete the termination of SMS in the SIM card

Return the ArrayList class object (convert it to the delete object)

example:

Import cn.com.chundi.sendsms. *;

Import java.util. *;

Public class deletemsg {

Public static void main (string args []) {

String index = NULL;

String begin = null;

String end = NULL;

SMS SMS1 = New SMS ();

IF (args.lendhe> 1) {

Begin = args [0];

End = args [1];

System.out.println ("IN" Begin "strips in SIM to the" end "bar text message ...................") ;

ArrayList Listmsg = SMS1.DELETEMSG (BEGIN, END);

IF (Listmsg == Null) {

System.out.println ("Delete Action Failed!");

}

Else {

INT TOTAL = Listmsg.size ();

For (int i = 0; i

Delete msg = (delete) list msg.get (i);

IF ((msg! = null) && (msg.isdelete () == true)) {

System.out.println ("No. msg.getno () " SMS successfully deleted);

}

Else {

System.out.println ("No. msg.getno () " SMS Delete Failure "in SIM);

}

}

}

}

Else {

IF (args.length> 0) {

INDEX = args [0];

System.out.println ("I'm deleting the" INDEX "SMS ..."); ");"); ");"

Delete

Del

= SMS1.DELETEMSG (INDEX);

IF

Del

! = null) && (DEL.ISDELETE () == True)) {

System.out.println ("The" INDEX "SMS in SIM Successfully Remove");

}

Else {

System.out.println ("The" Index "SMS in SIM");

}

}

}

}

}

Third, attached (READ class and DELETE class):

1, the READ class:

Int getno ()

Get the location of SMS in the SIM card

Boolean ISempty ()

Determines if the SMS is empty, returning True, getoa (), getTimeSTAMP (), getMsg () will return Null objects, indicating that there is no SMS in the GetNO () location in the SIM.

String getoa ()

Get SMS objects

String getTimeStamp ()

Get the reception time of SMS

String getmsg ()

Get SMS content

Realization of the READ class

Package cn.com.chundi.sendsms;

Public class read {

Public Read (int No, boolean empty) {

THIS.NO = NO;

THIS.EMPTY = EMPTY;

}

Public Read (int NO, String Oa, String Timestamp, String MSG) {

THIS.NO = NO;

THIS.OA = OA;

THIS.TimeStamp = TimeSTAMP;

THIS.MSG = MSG;

EMPTY = FALSE;

}

Public string getoa () {returna;}

Public string gettimestamp () {return timestamp;}

Public String getmsg () {return msg;}

Public int GetNo () {Return NO;

Public Boolean ISempty () {Return Empty;

PRIVATE BOOLEAN EMPTY = TRUE;

Private string oa = null;

Private string timestamp = NULL;

PRIVATE STRING MSG = NULL;

Private int No = 0;

}

2, DELETE class

Int getno ()

Get the location of SMS in the SIM card

Boolean isdelete ()

Determine if the SMS is deleted, and the time to return to TRUE successfully deleted

DELETE Class implementation:

Package cn.com.chundi.sendsms;

Public class delete {

Public Delete (int No, boolean

Del

) {

THIS.NO = NO;

THIS.DEL =

Del

;

}

Public int GetNo () {Return NO;

Public boolean isdelete () {return

Del

}

Private int No = 0;

Private boolean

Del

= FALSE;

} Gold flute message, communication is unlimited! http://www.sendsms.cn

转载请注明原文地址:https://www.9cbs.com/read-82682.html

New Post(0)