Reputation: 25874
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:
final static boolean
variable to conditionally execute code. I don't like this because of hardcoded variable.What do you think is the best approach to implement this behavior?
Upvotes: 1
Views: 182
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
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