Search code examples
c#android.netadbmadbee

Accessing android devices in C#


I am using MAD-Bee(Managed ADB) library to access ADB in C#. I am just trying to get list of devices attached to PC. I am getting list of devices properly when I use ADB from command prompt, but I get 0 in my C# form.
Here's the code I've tried -

    AndroidDebugBridge mADB;
    String mAdbPath;
    IList<Device> mDeviceList = null;
    public Form1()
    {
        InitializeComponent();
        mAdbPath = Environment.GetEnvironmentVariable("ANDROID_ROOT");
        mADB = AndroidDebugBridge.CreateBridge(mAdbPath + "\\platform-tools\\adb.exe", true);
        mADB.Start();

        var list = mADB.Devices;
        Console.WriteLine(""+list.Count);
    }

The problem is MAD-bee doesn't have any proper documentation or guide on how to start with it. Any help in this?


Solution

  • Woops found it now -

    List<Device> devices = AdbHelper.Instance.GetDevices ( AndroidDebugBridge.SocketAddress );
    

    More information is available in these tests -

    MadBee Tests