title: How to tell if USB is connected to android device?
body: <p>I've written an Android application and I would like the application to be able to recognize when the Android device is plugged into a PC via the USB or even better, know when it is connected and adb logcat is running. Is this possible?</p>
  
  <p>My purpose is to write traces to a separate circular buffer (which would get written to the sdcard occasionally) except when the device is connected e.g., via Eclipse and logcat is running - in that case, I would like to display the traces as part of logcat as they occur.</p>