当通过 USB 连接时,我正在使用 ADB 将文件从我的 java 应用程序推送到平板电脑。我希望能够通过 ADB 检测设备是否通过 USB 连接。我用来推送文件的代码是:
public void wiredsync(){
try {
abdsourcesync = buildpath;
adbtabletsync = "/mnt/sdcard/test";
System.out.println("Starting Sync via adb with command " + "adb" + " push "+ buildpath + " " + adbtabletsync);
Process process = Runtime.getRuntime().exec("adb" + " push "+ buildpath + " " + adbtabletsync);
InputStreamReader reader = new InputStreamReader(process.getInputStream());
Scanner scanner = new Scanner(reader);
scanner.close();
} catch(IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}//end wiredsync
如何修改此代码以确定平板电脑是否已连接?
谢谢您的帮助。
安迪