From the File menu select New > Project....

The New Project wizard is displayed. Select iDigi Android Project within the Android folder and click Next to start the wizard.

Enter a name for your project into the Project name field, for example HandleDoCommand. Then, select the Android API Level (version) to use for the project.

|
The name of the project must be unique in the workspace. If there is already a project with the same name inside the workspace, the wizard displays a message and will not continue until a different name is used. |
Optionally you can also change the Package name and Activity name for the project.
Click Finish to create the project.
When the project is created, it is displayed in the Package Explorer view. Expand it to see its contents.

Open the main activity file of the project to start editing it. The file is located under the src/<package name> folder of the project.

Double-click the file to open it in the main editor.
Replace the following lines:
|
// TODO: write your application code here: |
With this one:
|
iDigiServiceManager.subscribeDoCommand("myTarget", this); |
This line of code tells the application to listen for do_commands which have the myTarget string as a target (command identifier). Whenever a do_command having the target myTarget is sent to the embedded device, the application will execute the commandReceived() callback.
Replace the following lines:
|
// TODO: Write here the code you want to execute when a |
With these ones:
|
Toast.makeText(this,"do_command received: " + data.trim(),Toast.LENGTH_LONG).show(); |
The first line is the code that is executed when a do_command with the target myTarget is sent to the embedded device. It displays a pop-up with the data of the do_command. The second line returns the text that will be sent back to iDigi to indicate that the do_command has been received successfully.
Notice that you will need to import the toast control in order to display the toast (pop-up) message. To do so, write the following line in the imports section of the application code.
|
import android.widget.Toast; |
The file should now appear as follows:
Save the file and build the project. To do so, select the project from the Package Explorer view, right click on it and select the Build Project option from the context menu.

Before launching the application in the embedded device, you must ensure it is connected with the . To do so, click the Device Manager button from the Workbench's main toolbar:

Select the configuration you created previously. If the Debug Connection Status displays Disconnected, click the Connect button.
Once the device is connected with the , you can close the dialog and continue with the launch process.
The last step in the process is to launch the iDigi project. To do so, select the project from the Package Explorer view, right click on it and select the Run As > Android Application option from the context menu.
|
In the future, you can launch your project by clicking the Run button from the main toolbar.
|
This action will transfer and launch the iDigi Android application in your embedded device. Once the application is launched, the embedded device will display its main activity:
It is very important that the iDigi Connector for Android is running before you launch the application. You will know that it is running if the iDigi logo is displayed in the status bar. If iDigi was already running before you launched the application, you can continue with the next step, .
In this case the service was not running, as the logo is not displayed, so it is necessary to start the iDigi Connector for Android and execute the application again. To do so follow these steps:
|
Prev. Step |
Home |
Next Step |