AndroidController Class AndroidLib - Beatsleigher Edition
Controls communication to and from connected Android devices. Use only one instance for the entire project.
Inheritance Hierarchy

SystemObject
  RegawMOD.AndroidAndroidController

Namespace: RegawMOD.Android
Assembly: AndroidLib (in AndroidLib.dll) Version: 1.5.2.0 (1.5.2.0)
Syntax

public sealed class AndroidController

The AndroidController type exposes the following members.

Constructors

  NameDescription
Private methodStatic memberAndroidController
Private methodAndroidController
Initializes a new instance of the AndroidController class
Top
Methods

  NameDescription
Private methodCreateResourceDirectories
Public methodDispose
Releases all resources used by AndroidController
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Private methodExtractResources
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetConnectedDevice
Gets the first Device in the internal collection of devices controlled by AndroidController
Public methodGetConnectedDevice(String)
Gets a Device containing data about a specified Android device.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodCode exampleIsDeviceConnected(String)
Determines if the Android device with the serial number provided is currently connected
Public methodIsDeviceConnected(Device)
Determines if the Android device tied to device is currently connected
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodUpdateDeviceList
Updates Internal Device List
Public methodWaitForDevice
Pauses thread until 1 or more Android devices are connected
Top
Fields

  NameDescription
Private field_CancelRequest
Private fieldStatic memberANDROID_CONTROLLER_TMP_FOLDER
Private fieldconnectedDevices
Private fieldExtract_Resources
Private fieldStatic memberinstance
Private fieldm_eventWatcher
Private fieldm_monitorUSB
Private fieldresourceDirectory
Private fieldStatic memberRESOURCES
Top
Properties

  NameDescription
Public propertyCancelWait
Set to true to cancel a WaitForDevice() method call
Public propertyConnectedDevices
Gets a List<string> object containing the serial numbers of all connected Android devices
Public propertyHasConnectedDevices
Gets a value indicating if there are any Android devices currently connected
Public propertyStatic memberInstance
Gets the current AndroidController Instance.
Public propertyMonitorUSB
Gets or sets a value indicating whether this class shall monitor the USB (bus) and automatically check for new devices.
Protected propertyResourceDirectory
Top
Events

  NameDescription
Public eventCode exampleOnDeviceAdded
Occurs when a new Android device is added to the local machine.
Public eventOnDeviceRemoved
Top
Remarks

AndroidController is the core class in AndroidLib. You must always call the Dispose() method when finished before program exits.

AndroidController specifically controls the Android Debug Bridge Server, and a developer should NEVER try to start/kill the server using an AdbCommand

Examples

The following example shows how you can use the AndroidController class
// This example demonstrates using AndroidController, and writing the first connected Android device's serial number to the console
using System;
using RegawMOD.Android;

class Program
{
    static void Main(string[] args)
    {
        AndroidController android = AndroidController.Instance;
        Device device;
        string serialNumber;

        Console.WriteLine("Waiting For Device...");

        // This will wait until a device is connected to the computer
        // Should ONLY be used in Console applications though, as it freezes WinForm apps
        android.WaitForDevice();

        // Gets first serial number of Device in collection
        serialNumber = android.ConnectedDevices[0];

        // New way to set 'device' to the first Device in the collection
        device = android.GetConnectedDevice(serialNumber);

        Console.WriteLine("Connected Device - {0}", device.SerialNumber);

        android.Dispose();
    }
}

   // The example displays the following output:
   //        Waiting For Device...
   //        Connected Device - {serial # here}
See Also

Reference