先看一下官方的对Instrumentation的说明:
Base class for implementing application instrumentation code. When running with instrumentation turned on, this class will be instantiated for you before any of the application code, allowing you to monitor all of the interaction the system has with the application. An Instrumentation implementation is described to the system through an AndroidManifest.xml's <instrumentation> tag.
大概意思是说, Instrumentation 是一个可以在任何application执行代码之前,可以监视app和系统的交互。并且可以在AndroidManifest中配置。
Instrumentation是提供给开发人员写测试用例用的,它可以拦截和操作activity,application,发送按键,touch等工作。不过现在自动化测试已经有更好用的UiAutomation。
如果你研究过Android的源代码,就会发现Activity和ActivityThread中很多地方就用到了Instrumentation。
那我们就来看看它里面与我们接触最多的代码的流转过程。
Instrumentation的创建
版权声明:本文为bdmh原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。