public static boolean isDeviceConnected() { String command = "adb devices"; Runtime runtime = Runtime.getRuntime(); try { Process process = runtime.exec(command); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; while ((line = bufferedReader.readLine()) != null) { if (line.contains("device")) { return true; } } } catch (IOException e) { e.printStackTrace(); } return false; }