Creating the Example Android App

The following section describes the procedure to create the example Android App.

  1. Open Microsoft Visual Studio.
  2. Select Android in the sidebar, and create a new Blank App (Android) using .NET Framework 4.5. (Visual C# is used in this example).
  3. Set the Name and Solution Name properties to ‘ArasAndroid’
  4. Add any required references to the Solution. The following is required for this example:
    1. Right-click on References in the Solution Explorer and select Add References.
    2. Select the Browse tab and return IOM.Android.dll from the ‘bin\Debug’ folder of the Solution. The files can be copied to this location from the ‘\Utilities\Aras Innovator <Version> IOM SDK\COM\Android’ directory on the Aras Innovator CD Image.

In order to interact with the Android App, open the Resources --> layout --> Main.axml.

This example uses the default layout as shown in Figure 3.

Note
All functions which connect to Aras Innovator using asynchronous commands, including Events, will need to have the attribute “async” added to their definition, as demonstrated in this code.

Once you add the interactive elements to the App, configure a Click Event to ‘MyButton’ using the following code, modifying the properties where appropriate for the server:

// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);
button.Click += async delegate
{
//create connection to Innovator server
HttpServerConnection connection = IomFactory.CreateHttpServerConnection(“http://localhost/InnovatorServer/Server/InnovatorServer.aspx”, “InnovatorSolutions”, “admin”, “innovator”);
//login
try
{
Item user = await connection.LoginAsync();
}
catch (Exception e)
{
throw e;
}
//create innovator and send a request to the server
Innovator innovator = IomFactory.CreateInnovator(connection);
Item queryVariable = innovator.newItem(“Variable”, “get”);
queryVariable.setProperty(“name”, “IncludedSolutions”);
Item variable = await queryVariable.applyAsync();
if (variable.isError())
{
throw new Exception(variable.getErrorString());
}
button.Text = variable.getProperty(“value”);
};
Note
Commands which connect to Aras Innovator in the standard IOM.dll, such as “Login()” and “apply()”, have been replaced with asynchronous commands. You need to modify existing code to use the new asynchronous commands, such as “LoginAsync()” and “applyAsync()”, when converting existing projects to Android Apps. IOM functions which modify Item objects, such as “getProperty()”, “setAttribute()”, do not differ from the ones in the standard .NET IOM.