I have to identify at some place in my app that, whether my app is running in debug mode or live mode. Is there any function or piece of code available to check that. that returns true/false in either case on/off. if so, please help me out. Thanks in advance.
There are different way to check if the application is build using debug or release certificate, but the following way seems best to me. According to the info in Android documentation Signing Your Application, debug key contain following subject distinguished name: "CN=Android Debug,O=Android,C=US".
There are a few ways to see what apps are running in the background and consuming your Android's resources. Go to Settings > System > Developer Options. If you don't see Developer Options, scroll down and select About phone, then look for Build number and tap it seven times. Tap Running Services.
It is not clear from the question whether debug mode refers to:
The first is covered by CommonsWare's answer:
boolean isDebuggable = 0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE);
The second is:
boolean isBeingDebugged = android.os.Debug.isDebuggerConnected()
https://developer.android.com/reference/android/os/Debug.html#isDebuggerConnected()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With