3

If I connect an android smart phone through USB cable to a computer, I want to know if the connected device is running Android. Based on that I am going to show some notifications on the computer.

How to programmatically identify this from a windows PC?

I am trying to get a logic something similar to how Mobiledit does.

[Note: I cannot turn on USB debugging in the phone]

ozbek
  • 20,955
  • 5
  • 61
  • 84
Deepak Raj
  • 730
  • 2
  • 9
  • 26
  • You could run `adb devices` before and after the new connection and compare the results. – FD_ May 22 '14 at 12:13
  • In order to use ADB, you have to enable USB Debugging option in phone settings. I cannot do that. Also I want to know this exclusively from a c# application running in windows PC, without using other apps. – Deepak Raj May 22 '14 at 12:23
  • thanks FD_, I edited the question as well for clarity – Deepak Raj May 22 '14 at 12:33
  • 2
    What other constraints do you have ? Currently the only options other than adb are programmatically maintaining a vendor and product id list [Generic List used by Linux](http://www.linux-usb.org/usb.ids) of devices that are capable of running Android based from the vendors in [ADB's Vendor List](https://android.googlesource.com/platform/system/core/+/master/adb/usb_vendors.c), sniffing the the USB traffic for some magic injected USB signature or other type of USB traffic signature fingerprinting if possible, or trying to fingerprint based on directory structure of automounted SD cards. – Appleman1234 Jun 14 '14 at 03:29
  • check this link [How to know when Android device is plugged into USB port? [closed]](http://stackoverflow.com/questions/21222343/how-to-know-when-android-device-is-plugged-into-usb-port?answertab=active#tab-top) – user3749485 Jun 17 '14 at 21:18

1 Answers1

1

You can list connected devices using Windows Portable Devices API, and then filter results, using list of possible android devices as Appleman1234 suggested. Problem is that far as I know WPD API doesn't have C# wrapper so you'll have to use PInvoke to write your own.

There are 2 articles on MSDN which can help:

  1. Creating a Temperature-Sensor Gadget for Windows Sidebar with C# - basics of using WPD with c# and PInvoke.
  2. Enumerating devices using WPD API in C++
Redwan
  • 738
  • 9
  • 28
  • Actually I've found a list of blog posts showing how to use WPD in C#, check this and previous articles: http://cgeers.com/2011/08/13/wpd-transferring-content/ – ocramot May 14 '15 at 08:17