I'm anxiously awaiting the open source release of StrictMode for continuation of our platform development. The sample in the Android blog entry suggests surrounding the StrictMode calls with
if (DEVELOPER_MODE) {
...
}
For SDK development, I'd expect this constant to be locally defined by each application. However, for platform development, is android.util.Config.DEBUG
the best way to determine whether to turn this on?
It's an old question, but I'd like to mention that the closest alternative I can imagine is BuildConfig.DEBUG
for application engineers. It returns whether this is a debug build.
Sorry, DEVELOPER_MODE
was just an arbitrary name I picked for the blog post and Javadoc. Perhaps I should make that more clear in the docs.
I'd imagined people would make their own hard-coded,
private static final boolean DEVELOPER_MODE = false;
... that they maintain by hand, but looks like Config.DEBUG
would have been a better thing to use. I didn't even know about that! :)
Config.DEBUG is not going to actually works since it is pretty much always set to false. It is better to look at the debuggable attribute in the AndroidManifest file . I have documented it on a blog post. Links are with this answer
To Answer my own question... As a platform developer (one using Android to create a device), the Activity Manager in Android automatically enables StrictMode on the main thread for all apps installed on the System Partition whenever the platform is built with an eng or userdebug built. I agree with Manfred that Config.DEBUG is not appropriate for SDK developers. Essentially, platform developers writing applications which are loaded by default on the System Partition don't have to do anything to take advantage of StrictMode - the platform does it for them.
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