How do i know at runtime in Android if it is a test environment runned from Eclipse or a signned version installed from the Market? (i need to run some debug code only when testing, because in live i get some ANR reports caught when running this code)
Asked
Active
Viewed 195 times
2 Answers
0
You dont need to. You can just log them in Log.d level and then use a tool such as ProGuard to remove such logs
http://proguard.sourceforge.net/
More explanation in this answer Remove all debug logging calls before publishing: are there tools to do this?
EDIT
If that is the case you need to have some sort of boolean value in an external properties file and conditonally write logs.
More info on that here Variables from properties file in Ant
-
thank you for your answer but this is not what i have asked, i do not only need to remove Log messages, but some other code too, so the only thing a need is a simple true/false condition before running the debug code. Is this possible? – user1804542 Feb 15 '13 at 06:49
0
According to http://android-developers.blogspot.co.uk/2010/09/securing-android-lvl-applications.html
boolean isDebuggable = ( 0 != ( getApplcationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE ) );
will let you know it if is debuggable, you can then save this to a shared pref or some other method and then check it whenever you want.

Paul Harris
- 5,769
- 1
- 25
- 41