Usb Debugging connected state

242 views Asked by At

Is there any way to findout the device connected to PC with USB debugging? Inside the app. not from ADB

enter image description here

Clarification:

  • It's not about checking USB Debugging on [Assume it's always on]
  • Not Listening to this event

I tried with following hack:

private boolean isConnected() {
    IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    Intent batteryStatus = this.registerReceiver(null, ifilter);
    int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
    return status == BatteryManager.BATTERY_STATUS_CHARGING;
}

Not working with all devices. (esp. tablets)

0

There are 0 answers