0

I think this function means that device is connected by USB cable and that device is configured for debugging( debug mode is set on the device).

Java Compiler on Android Studio reports that 'Debug' is undefined. What is the import package?

resander
  • 1,181
  • 2
  • 11
  • 15

1 Answers1

1

Try

import android.os.Debug;

https://developer.android.com/reference/android/os/Debug#isDebuggerConnected()

coderms
  • 96
  • 6
  • Nice! The package in your reply is the one! Many thanks. – resander Dec 02 '20 at 17:36
  • Glad to know it helped. Please mark it as accepted. – coderms Dec 02 '20 at 18:39
  • I disconnected the USB cable from the Samsung 51 device and checked with breakpoint after statement boolean deviceconnected = Debug.isDebuggerConnected(); Variable deviceconnected came out 'true' but the device was not connected with USB cable. Maybe Debug.isDebuggerConnected() just means debug is ON (connecting to debugging) only. – resander Dec 02 '20 at 19:23
  • From the documentation of isDebuggerConnected() API, it doesn't mention anything about USB connected. If your goal is to check if USB is connected, try https://stackoverflow.com/questions/4600896/android-detecting-usb – coderms Dec 03 '20 at 09:19