private void waitUntilConnected ( AndroidDebugBridge adb ) { int trials = 10 ; final int connectionWaitTime = 50 ; while ( trials > 0 ) { try { Thread . sleep ( connectionWaitTime ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } if ( adb . isConnected ( ) ) { break ; } trials -- ; } }
Run a wait loop until adb is connected or trials run out . This method seems to work more reliably then using a listener .