m0skit0
m0skit0

Reputation: 25874

Best approach to switch debug on/off

My scenario is the following: I have a remote service with which any application can communicate through Messenger. Applications send custom events I defined. Each event define an "action" to be performed (similar to Android's Intent). To test the event sending and processing by the service, I want to set up a new event action (e.g. EventAction.DEBUG), but I don't want this action and the code that processes it to be present in the release, .

This is what I thought:

What do you think is the best approach to implement this behavior?

Upvotes: 1

Views: 182

Answers (2)

XGouchet
XGouchet

Reputation: 10203

Android's ADT version 17 and higher already include a BuildConfig.DEBUG variable which is set to false when exporting a signed APK (for release).

Upvotes: 2

Dave Newton
Dave Newton

Reputation: 160271

A final static. ProGuard will remove the unused code.

Regarding a config file value--it's only "useless" if it can never ever change during runtime, and a compare isn't all that slow, really, when compared to the rest of the app.

Upvotes: 4

Related Questions