Getting the "debug" value of androidManifest from code?

I wrote a wrapper on top of Log.java that is provided by android. My class will add some other application level features to the logs.

Now the whole thing is that I want to check the code whether the "debugged" is set to "true" or "false" in the androidManifest.xml file.

Can I do it? If so, how?

Thanks in advance.

+48
android
Nov 25 '10 at 12:06
source share
2 answers

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

 boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)); 
+98
Nov 25 2018-10-25
source share

Now you can use the BuildConfig.DEBUG static boolean field to achieve the same. This class is created at compile time and can be seen in your gen folder.

+52
Sep 10
source share



All Articles