How to create a breakpoint programmatically on Android
I think that Debug.isDebuggerConnected()
is what you are looking for. This will return true
only if the app is started with debugger attached and false
otherwise, no matter of build type
or flavor
. Unfortunately, I don't think that you can stop the execution programatically, but with the above instruction you should be able to display an error message or throw an exception. Personally, I'm thinking to something like this:
if (Debug.isDebuggerConnected()) {
// throw an exception for the developer with a detailed message
} else {
// show the general error message to the user with a dialog/toast
}