/// <summary> /// Perform the action. /// </summary> protected override void DoWork() { // Listen for devices deviceMonitor.Start(); deviceMonitor.WaitForInitialUpdate(); // Perform the connect connecting = true; var adb = new Adb { Logger = LogOutput }; adb.Connect(host, port, Adb.Timeout.Connect); }
static void Main(string[] args) { ADB.Connect(IPAddress.Parse("10.1.112.48")); PrintDevices(); var device = ADB.UpdateDevices()[0]; // wake the device's screen device.ExecuteShellCommand(true, "input keyevent KEYCODE_POWER"); // get a screenshot var x = device.ExecuteShellCommand(false, "screencap", "-p"); using (BinaryWriter writer = new BinaryWriter(File.Create("test.png"))) writer.Write(x); }
private void connectBtn_Click(object sender, EventArgs e) { ThreadPool.QueueUserWorkItem(o => { try { toolStripStatusLabel.Text = "Connecting..."; if (!ADB.Connect(IPAddress.Parse(string.Format("{0}.{1}.{2}.{3}", ip1.Text, ip2.Text, ip3.Text, ip4.Text)), int.Parse(port.Text))) { MessageBox.Show("Connection to the device has failed.", "Android.NET Example", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "ADB.NET Example", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { toolStripStatusLabel.Text = "Ready..."; } }); }