我可以通过“instruments -s device”命令获取所有可用设备。
但我不知道哪一个是活动设备。请问如何在JAVA程序中编程识别活动设备或模拟器。
请帮忙解答,谢谢。
我可以通过“instruments -s device”命令获取所有可用设备。
但我不知道哪一个是活动设备。请问如何在JAVA程序中编程识别活动设备或模拟器。
请帮忙解答,谢谢。
$ xcrun simctl list devices | grep 'Booted'
iPhone 5 (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) (Booted)
虽然最初要求用JAVA编程,但以下内容可能会对某些人有所帮助。
获取所有活动的iOS物理设备和iOS模拟器及其UDID:
$ xcrun xctrace list devices
查找带有其UDID的活动iOS模拟器:
$ xcrun simctl list | grep Booted
BufferedReader in = new BufferedReader(new InputStreamReader( processUDID.getInputStream())); Stream<String> stream = in.lines(); stream.forEach(s -> {
if (s.contains("Booted")) { String ud = deviceUdid = s.substring(s.indexOf("-") - 8) .trim(); ud = deviceUdid = ud.substring(0, ud.indexOf(")")).trim(); simulatorUdid = ud; }
});` - VSK