Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Definition of DEVELOPER_MODE for StrictMode

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?

like image 742
Dave Boldt Avatar asked Dec 15 '10 15:12

Dave Boldt


4 Answers

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.

like image 55
Teng-pao Yu Avatar answered Sep 23 '22 17:09

Teng-pao Yu


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! :)

like image 31
Brad Fitzpatrick Avatar answered Nov 12 '22 07:11

Brad Fitzpatrick


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

like image 4
Manfred Moser Avatar answered Nov 12 '22 07:11

Manfred Moser


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.

like image 1
Dave Boldt Avatar answered Nov 12 '22 08:11

Dave Boldt