As far as I know, in android “release build” is signed APK. How to check it from code or does Eclipse has some kinda of secret defines?
I need this to debug populating ListView items from web service data (no, logcat not an option).
My thoughts:
- Application’s
android:debuggable, but for some reason that doesn’t look reliable. - Hard-coding device ID isn’t good idea, because I am using same device for testing signed APKs.
- Using manual flag somewhere in code? Plausible, but gonna definitely forget to change at some time, plus all programmers are lazy.
There are different way to check if the application is build using debug or release certificate, but the following way seems best to me.
According to the info in Android documentation Signing Your Application, debug key contain following subject distinguished name: “CN=Android Debug,O=Android,C=US“. We can use this information to test if package is signed with debug key without hardcoding debug key signature into our code.
Given:
You can implement an isDebuggable method this way: