Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "debuggable" value of androidManifest from code?

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?

like image 646
ABDroids Avatar asked Nov 25 '10 12:11

ABDroids


2 Answers

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));
like image 151
CommonsWare Avatar answered Oct 19 '22 02:10

CommonsWare


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.

like image 55
Snicolas Avatar answered Oct 19 '22 01:10

Snicolas