开发者

Getting "debuggable" value of androidManifest from code?

开发者 https://www.devze.com 2023-01-27 10:17 出处:网络
I\'ve written a wrapper on top of Log.java that is provided by android. My Cla开发者_运维知识库ss will add some other application level features in Logs.

I've written a wrapper on top of Log.java that is provided by android. My Cla开发者_运维知识库ss 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?


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));


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消