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:

  1. Create a folder called lib in the root of your project.

    Lib folder

  2. 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.

    Tip

    If you have more than 1 version installed, it is recommended to use the latest one.


  3. Copy the idigi_android.jar library and paste it into the lib folder of your project.

    Library copied

  4. Select your project from the list of projects, then right-click on it and select Properties.

  5. Select Java Build Path from the left menu and go to the Libraries tab.

    Java Build Path

  6. Click the Add JARs... button then select the idigi_android.jar library from your project and click OK.

    Java Build Path

  7. 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.

Manifest

To add the first receiver (DoCommandReceiver), follow these steps:

  1. Click the Add... button under the Application Nodes section. Select Receiver from the list and click OK.

    Add Receiver item

  2. Select the newly added Receiver and give it the following name: com.digi.android.idigi.library.core.DoCommandReceiver.

    Receiver name

  3. Select the Receiver and click the Add... button. Select IntentFilter and click OK.

    Add IntentFilter item

  4. Select the IntentFilter and click the Add... button. Select Action and click OK.

    Add Action item

  5. Select the newly added Action and give it the following name: com.digi.android.idigi.DO_COMMAND.

    Action name

  6. Select the IntentFilter again and click the Add... button. Select Category and click OK.

    Add Category item

  7. Select the newly added Category and choose the following name from the drop-down list: android.intent.category.HOME.

    Category name

  8. Save the file.

You have just added the first receiver. To add the second one (SendFileStatusReceiver) you need to repeat the previous process:

  1. Unselect any item and click the Add... button. Select Receiver from the list and click OK.

    Add Receiver item

  2. Select the newly added Receiver and give it the following name: com.digi.android.idigi.library.core.SendFileStatusReceiver.

    Receiver name

  3. Select the Receiver and click the Add... button. Select IntentFilter and click OK.

    Add IntentFilter item

  4. Select the IntentFilter and click the Add... button. Select Action and click OK.

    Add Action item

  5. Select the newly added Action and give it the following name: com.digi.android.idigi.UPLOAD_FILE_STATUS.

    Action name

  6. Select the IntentFilter again and click the Add... button. Select Category and click OK.

    Add Category item

  7. Select the newly added Category and choose the following name from the drop-down list: android.intent.category.HOME.

    Category name

  8. Save the file.

The process for adding the third receiver (DeviceIDReceiver) is fairly similar to the previous ones:

  1. Unselect any item and click the Add... button. Select Receiver from the list and click OK.

    Add Receiver item

  2. Select the newly added Receiver and give it the following name: com.digi.android.idigi.library.core.DeviceIDReceiver.

    Receiver name

  3. Select the Receiver and click the Add... button. Select IntentFilter and click OK.

    Add IntentFilter item

  4. Select the IntentFilter and click the Add... button. Select Action and click OK.

    Add Action item

  5. Select the newly added Action and give it the following name: com.digi.android.idigi.DEVICE_ID.

    Action name

  6. Select the IntentFilter again and click the Add... button. Select Category and click OK.

    Add Category item

  7. Select the newly added Category and choose the following name from the drop-down list: android.intent.category.HOME.

    Category name

  8. Save the file.

Now you need to configure iDigi permissions in the manifest file. The following permissions will be added:

  1. com.digi.android.idigi.DATA_SERVICE: This permission is used to allow the application to upload data to iDigi.
  2. com.digi.android.idigi.DO_COMMAND: This permission is used to allow the application to listen for commands from iDigi.

Go to the Permissions tab of the manifest file.

Permissions tab

Perform the following steps:

  1. Click the Add... button. Select Uses Permission and click OK.

    Uses permission item

  2. Select the newly added permission and give it the following name: com.digi.android.idigi.DATA_SERVICE.

    Data service permission

  3. Click the Add... button again. Select Uses Permission and click OK.

    Uses permission item

  4. Select the newly added permission and give it the following name: com.digi.android.idigi.DO_COMMAND.

    Do command permission

  5. Save the file.

If you go to the AndroidManifest.xml tab of the manifest file, you should see something similar to this:

Manifest summary

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.

Main Activity

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;
import com.digi.android.idigi.library.core.IDigiServiceManager;

Code Imports

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

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:

Add unimplemented methods

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.

commandReceived method

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
IDigiServiceManager iDigiServiceManager = new IDigiServiceManager(this)

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.

iDigi Service Manager methods