Hi everybody,
I want to run adb command to connect another android device via wlan.
I meet some problem while i trying
I has poor knowlege about java so i try chatgpt but codes it gave does not work
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.runtime.util.YailList;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@DesignerComponent(version = AdbExtension.VERSION,
description = "An extension for executing ADB commands without root",
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = "images/extension.png")
@SimpleObject(external = true)
public class AdbExtension extends AndroidNonvisibleComponent {
public static final int VERSION = 1;
public AdbExtension(ComponentContainer container) {
super(container.$form());
}
@SimpleFunction(description = "Execute ADB command without root")
public YailList executeAdbCommand(String command) {
YailList outputList = new YailList();
try {
Process process = Runtime.getRuntime().exec("adb " + command);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
outputList.add(line);
}
process.waitFor(); // Wait for the command to finish
} catch (IOException | InterruptedException e) {
e.printStackTrace();
outputList.add("Error: " + e.getMessage());
}
return outputList;
}
}
I recently came across your post about developing an ADB extension and was wondering how your project is progressing. I’m interested in learning more about any updates or challenges you might have encountered.
If you’re comfortable sharing, could you provide an update on the current status of your project? Any new developments or insights would be greatly appreciated.
Thank you for your time, and I look forward to hearing from you!