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;
}
}
how can i make it
(my english does not well....