The fastest and easiest way to create an iDigi Android project is by using the iDigi Android wizards that are installed with the iDigi Connector. However, you may have previously developed an Android project that you now want to give iDigi functionality to. The following steps will guide you through the process of giving iDigi functionality to an existing Android project.
The iDigi Android library provides the necessary API to communicate with iDigi. This library is copied and linked to the project automatically when creating a project using any iDigi Android wizard. To copy and link it manually, follow these steps:
Create a folder called lib in the root of your project.

Go to the path of the Eclipse version you are using and navigate to plugins/com.digi.android.iik.data_<version>/Sources/Library, where <version> is the version of the iDigi Connector you have installed.
|
If you have more than 1 version installed, it is recommended to use the latest one. |

Select your project from the list of projects, then right-click on it and select Properties.
Select Java Build Path from the left menu and go to the Libraries tab.
Click the Add JARs... button then select the idigi_android.jar library from your project and click OK.

Click OK in the Properties dialog to accept the changes.
Next you will configure iDigi preferences within the application's manifest. To do so you will need to add 2 application receivers and 2 application permissions. Double-click on the AndroidManifest.xml file of your project to open it.
The application receivers will enable the application to listen for concrete iDigi intents. You will need to add 2 receivers:
Go to the Application tab of the manifest file.
To add the first receiver (DoCommandReceiver), follow these steps:
Click the Add... button under the Application Nodes section. Select Receiver from the list and click OK.

Select the newly added Receiver and give it the following name: com.digi.android.idigi.library.core.DoCommandReceiver.
Select the Receiver and click the Add... button. Select IntentFilter and click OK.
Select the IntentFilter and click the Add... button. Select Action and click OK.
Select the newly added Action and give it the following name: com.digi.android.idigi.DO_COMMAND.
Select the IntentFilter again and click the Add... button. Select Category and click OK.
Select the newly added Category and choose the following name from the drop-down list: android.intent.category.HOME.
Save the file.
You have just added the first receiver. To add the second one (SendFileStatusReceiver) you need to repeat the previous process:
Unselect any item and click the Add... button. Select Receiver from the list and click OK.

Select the newly added Receiver and give it the following name: com.digi.android.idigi.library.core.SendFileStatusReceiver.
Select the Receiver and click the Add... button. Select IntentFilter and click OK.
Select the IntentFilter and click the Add... button. Select Action and click OK.
Select the newly added Action and give it the following name: com.digi.android.idigi.UPLOAD_FILE_STATUS.
Select the IntentFilter again and click the Add... button. Select Category and click OK.
Select the newly added Category and choose the following name from the drop-down list: android.intent.category.HOME.
Save the file.
The process for adding the third receiver (DeviceIDReceiver) is fairly similar to the previous ones:
Unselect any item and click the Add... button. Select Receiver from the list and click OK.

Select the newly added Receiver and give it the following name: com.digi.android.idigi.library.core.DeviceIDReceiver.
Select the Receiver and click the Add... button. Select IntentFilter and click OK.
Select the IntentFilter and click the Add... button. Select Action and click OK.
Select the newly added Action and give it the following name: com.digi.android.idigi.DEVICE_ID.
Select the IntentFilter again and click the Add... button. Select Category and click OK.
Select the newly added Category and choose the following name from the drop-down list: android.intent.category.HOME.
Save the file.
Now you need to configure iDigi permissions in the manifest file. The following permissions will be added:
Go to the Permissions tab of the manifest file.
Perform the following steps:


Save the file.
If you go to the AndroidManifest.xml tab of the manifest file, you should see something similar to this:
Now that you have configured all of the necessary iDigi settings for your project, it is time to use the iDigi Connector for Android in code. To do so, open your main activity file to edit it.
Add the following lines in the imports section to be able to use the IDigiServiceManager class and the IDoCommandListener interface:
|
import com.digi.android.idigi.library.core.IDoCommandListener; |
If you want to enable your activity to listen for iDigi do_commands, you need to implement the IDoCommandListener interface. To do so, write the following text next to the activity definition:
|
implements IDoCommandListener |
You will notice that the activity definition is now underlined in red. This is because it is missing a method needed by the IDoCommandListener interface. To add the missing method hover over the activity definition until you see the following dialog:

Click on Add unimplemented methods to automatically add the missing method to your activity. You will find it in the code with the following name: commandReceived.
This method is executed whenever the activity receives a do_command it has previously subscribed.
In order to communicate with iDigi to send files, subscribe for do_commands, etc., you need to get an instance of the IDigiServiceManager. To do so, go to the onCreate method of your activity and write the following lines:
|
// Get an instance of the iDigi Service Manager |
Now you can use that object to send files to iDigi, subscribe to do_commands with specific targets, etc. If you write the following text and press CTRL+SPACE you can see a list with all the methods of the IDigiServiceManager:
|
iDigiServiceManager. |
