AndroidControllerOnDeviceAdded Event AndroidLib - Beatsleigher Edition
Occurs when a new Android device is added to the local machine.

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

public event DeviceAddedEventHandler OnDeviceAdded

Value

Type: RegawMOD.AndroidDeviceAddedEventHandler
Examples

Example use of this event: Please note that these example are not recommended for WPF. For WPF, please consider the MVVM pattern.
C# Example (Lambda)
public class FooBar {

    private readonly AndroidController m_adbController;

    public FooBar() {
        m_adbController = AndroidController.Instance;
        m_adbController.MonitorUSB = true; // If you set this to <c>false</c>, USB ports will not be monitored, thus, events will not be fired.
        m_adbController.OnDeviceAdded += (s, evt) => {
            MessageBox.Show(string.Format("A new device was added!\nSerial: {0}", evt.Device.Serial));
            // Do more
        };
    }
}
C# Example (Conventional)
public class FooBar {

    private readonly AndroidController m_adbController;

    public FooBar() {
        m_adbController = AndroidController.Instance;
        m_adbController.MonitorUSB = true; // If you set this to <c>false</c>, USB ports will not be monitored, thus, events will not be fired.
        m_adbController.OnDeviceAdded += adbController_OnDeviceAdded;
    }

    private void adbController_OnDeviceAdded(object m_sender, OnDeviceAddedEventArgs m_eventArgs) {
        MessageBox.Show(string.Format("A new device was added!\nSerial: {0}", evt.Device.Serial));
        // Do more
    }
}
Visual Basic Example (Lambda)
Public Class FooBar

    Private ReadOnly m_adbController As AndroidController

    Public Sub New()
        m_adbController = AndroidController.Instance
        m_adbController.MonitorUSB = True ' If you set this to False, USB ports will not be monitored, thus, events will not be fired.
        m_adbController.OnDeviceAdded += Function(s, evt)
                                            MessageBox.Show(String.Format("A new device was added!{0}Serial: {1}", vbNewLine, evt.Device.Serial))
                                            ' Do more
                                         End Function
    End Sub

End Class
Visual Basic Example (Conventional)
Public Class FooBar

    Private ReadOnly m_adbController As AndroidController

    Public Sub New()
        m_adbController = AndroidController.Instance
        m_adbController.MonitorUSB = True ' If you set this to False, USB ports will not be monitored, thus, events will not be fired.
    End Sub

    Private Sub m_adbController_OnDeviceAdded(Object m_sender, OnDeviceAddedEventArgs m_eventArgs) Handles m_adbController.OnDeviceAdded
        MessageBox.Show(String.Format("A new device was added!{0}Serial: {1}", vbNewLine, evt.Device.Serial))
        ' Do more
    End Sub

End Class
See Also

Reference