Currently I am using the debuggable attribute in the manifest which is not initially set in file since Eclipse frowns on this. Then in my ant script I have created a custom_rules.xml where I set the property in the manifest manually based on the targets false if release and true if debug version.
<target name="-set-debug-files" depends="-set-mode-check">
.....
<!-- alter the app manifest to reflect the testing state -->
<property name="match.start" value="android:debuggable="/>
<property name="match.end" value=">"/>
<replaceregexp file="AndroidManifest.xml"
match="${match.start}.*${match.end}"
replace="${match.start}"true"${match.end}">
</replaceregexp>
<echo level="info">${ant.project.name}
setting manifest debug state to true</echo>
</target>
<target name="-set-release-mode" depends="-set-mode-check">
......
<property name="match.start" value="android:debuggable="/>
<property name="match.end" value=">"/>
<replaceregexp file="AndroidManifest.xml"
match="${match.start}.*${match.end}"
replace="${match.start}"false"${match.end}">
</replaceregexp>
<echo level="info">${ant.project.name}
setting manifest debug state to false</echo>
</target>
Then in code I placed in my custom Application class I created a static I can reference in my activities.
DEBUG = (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
Then when I need to hide/show stuff I use:
if (MyApplication.DEBUGGABLE) {
...show stuff
} else {
...hide stuff
}