I have one question about finding if your application is in release mode or in debug. I need to find a way to detect the applications mode automatically with a function. For now I'm using a simple way declaring a boolean
which everytime I have to change true/false
. But sometimes me, or the other developer may forget to change it. Actually I need this because, I'm using an error handler in my app which is sending to our server exceptions which are uncaught. And I don't want to do this in debug mode.
So is there any way I can detect this with some functions which my app will do automatically, without using any variables like I do?
There is no general solution but you may use isDebuggerConnected .
BUT this solution would also trigger/show the debug features if your users connect their phones to the PC and uses ddms themselves.
Maybe you sould combine this with one of the checks Aleks G suggested, and popup a Toast-message on every start that reminds you to disable debug ;-)
Why not use this?
if (BuildConfig.DEBUG) {
// what shall happen in debug version
} else {
// release version
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.