Getting "debuggable" value of androidManifest from code?

AndroidAndroid Manifest

Android Problem Overview


I've written a wrapper on top of Log.java that is provided by android. My Class will add some other application level features in Logs.

Now the things is that I want to check from the code whether "debuggable" is set to 'true' or 'false' in androidManifest.xml file.

Can I do that? If yes, how?

Android Solutions


Solution 1 - Android

Use PackageManager to get an ApplicationInfo object on your application, and check the flags field for FLAG_DEBUGGABLE.

boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));

Solution 2 - Android

You can now use the static boolean field BuildConfig.DEBUG to achieve the same thing. This class is generated during compilation and can be seen in your gen folder.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionABDroidsView Question on Stackoverflow
Solution 1 - AndroidCommonsWareView Answer on Stackoverflow
Solution 2 - AndroidSnicolasView Answer on Stackoverflow