title: How to tell if android device detected by ADB?
body: <p>I am using ADB to push files from my java application to a tablet when its connected via USB.  I would like to be able to detect if a device is connected or not via USB by ADB.  The code I am using to push the files across is:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>How can I modify this code to work out if a tablet is connected or not?</p>
  
  <p>Thanks for the help.</p>
  
  <p>Andy</p>