English 中文(简体)
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?

问题回答

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.

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.





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签