Search code examples
testingruntimeliveenvironment

How do i know at runtime in Android if it is a test or a live environment?


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)


Solution

  • 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.