获得“可调试"来自代码的 androidManifest 的值? [英] Getting "debuggable" value of androidManifest from code?

查看:38
本文介绍了获得“可调试"来自代码的 androidManifest 的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 android 提供的 Log.java 之上编写了一个包装器.My Class 将在日志中添加一些其他应用程序级别的功能.

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.

现在的事情是我想从代码中检查 androidManifest.xml 文件中的debuggable"是否设置为true"或false".

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?

推荐答案

使用 PackageManager 获取应用程序上的 ApplicationInfo 对象,并检查 flags<FLAG_DEBUGGABLE 的/code> 字段.

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

这篇关于获得“可调试"来自代码的 androidManifest 的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆