THE SIMULATION EXPERIMENT OF SMS & CALL – Android Mobile

The main function of SMS is to send text messages and receive text messages, in this section, it simulates sending and receiving text messages. In order to realize the simulation experiment of SMS, it requires two simulators, one for sending text messages and the other for receiving text messages. Developer can configure the development environment and create emulators according to the method described in section III. In this section, the simulator named A is created to send text messages and its number is 5554 then the simulator named B is created to receive text messages and its number is 5556. SL4 and PFA are installed on the simulator named A.To achieve SMS, two files are written, one is an XML file for interface layout, and the other is a PHP file that reads the layout and responds to event and implements functions codeshoppy.com

A. Interface Layout The entire interface consists of two text edit boxes and a button. The first text edit box whose ID is editNumber is used to edit the phone number, the second text edit boxwhose ID is editText is used to edit the text message content,the button whose ID is send is used to send text messages.

B. Function Implementation 1) Start the program and read the interface layoutIn the PHP file, some of the codes are used to start the program and read the interface layout. The system has two global variables, one is the class variable $droid and the other is $layout. The $droid, a class variable, is an android object that can access the android native services provided by SL4A, the variable $layout is used to get the interface layout from the XML file. When the application is started, the application creates the variable $droid and $layout and reads the layout. The main codes are shown below: require_once(“Android.php”); $droid = new Android(); $layout=file_get_contents (“/sdcard/sl4a/scripts/mylayout.xml”);$droid->fullShow($layout); 2) Event responseIn the PHP file, part of the code is used to respond to events. The user clicks the button to generate the click event.When the clicked button’s ID is “sent “, the event will be generated and send the edited text message to the specified emulator. The event response code is shown below:$event=$droid->eventWait(1000000); $event=$event[‘result’]; if ( ($event->name==”click”) && ($event->data->id==”send”) ) { $phonneNumber=$droid->fullQueryDetail(“editNumber”);$phonneNumber=$phonneNumber[‘result’]->text;$sendMsg=$droid->fullQueryDetail(“editText”);$sendMsg=$sendMsg[‘result’]->text;$droid->smsSend($phonneNumber,$sendMsg);}

C. Run the Program and Display the Results After opening the simulator named A andthe simulator named B, firstly developer can find the file of DDMS. bat in the directory of D: \ android SDK and open the DDMS tool. Then the XML file and the PHP file have been copied to the directory of /sdcard/sl4a/scripts/ in the simulator named A by DDMS tool. Finally, developer can click the SL4A icon in the simulator named A and open the SL4A manager, and then click on the PHP file in the file list to run the PHP file. After running the PHP file, the emulator named A will have an interface that includes two text edit boxes and one button from top to bottom. The first text edit box is used to edit the phone number, the second text edit box is used to edit text messages, and the button is used to send text messages. If the phone number that is entered is “5556” and the text message that is sent is “Hello”,when the button of send message is clicked, the simulator named A will send the text message to the simulator named B , at the same time the simulator named B will receive the text message from the simulator named A.

The main function of call is to call and answer the phone,in this section, it simulates calling and answering the phone.In order to realize the simulation experiment of call, it requires two simulators, one for calling and the other for answering. Developer can configure the development environment and create emulators according to the method described in section III. In this section, the simulator named A is created to call the phone and its number is 5554, then the simulator named B is created to answer the phone and its number is 5556. SL4 and PFA are installed on the simulator named A and the simulator named B. The main codes are shown below:<? phprequire_once(“Android.php”);$droid = new Android(); $ret=$droid->makeIntent(“android.intent.action.DIAL”,”tel:5556″);$droid->startActivityIntent($ret[‘result’]); ?>In order to run the code and implement the function of call, firstly developer should open the simulator named A and simulator named B, then the PHP file have been copied to the directory of /sdcard/sl4a/scripts/ in the simulator named A by DDMS tool and the PHP file is run. Afterrunning the PHP file, the emulator named A will have adial-up interface, if the phone number that is entered is “5556”, when the button of dialing isclicked, the simulator named A will dial to the simulator named B , at the same time the simulator named B will have an incoming call from the simulator named A. View More