Android check if app debug or release

In android JUnit test, we may need to know if the target app is debug version or release version.

Context mContext = InstrumentationRegistry.getTargetContext();
ApplicationInfo mApplicationInfo = mContext.getPackageManager().getPackageInfo(PACKAGE_NAME, 0).applicationInfo;
boolean isDebuggable = (0 != (mApplicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE));

And we can check other flags using this, FLAG_ALLOW_CLEAR_USER_DATA etc.

As for & in inta & intb:

int a = Integer.parseInt("1010", 2);
int b = Integer.parseInt("0111", 2);
System.out.println(a & b);
System.out.println(Integer.toBinaryString(a & b));

prints:

2
10
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Correctness AdapterViewChildren Summary: AdapterViews can...
    MarcusMa阅读 8,925评论 0 6
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,991评论 19 139
  • 首先说说自己对简书的初步印象吧,前两天在上网偶然发现简书,出于自己从事互联网产品工作形成的习惯爱好就下载了个App...
    克果阅读 323评论 2 2
  • 看了这么多电影,这部是主动想写点东西的 电影其他的不想多说最让我念念不忘的是男主的一群“合伙人” 他称他们为合伙人...
    Zzzxy阅读 284评论 0 0
  • 有了文字后,人类通过文字创造出想象的现实,可以让更多互不相识的人们有效合作,而且效果还不止如此。正由于大规模的人类...
    兼善天下阅读 471评论 0 0