带有startInstrumentation的Android应用程序
我想从测试的应用程序内部使用接口插入我的应用程序。 我有一个自定义活动,我的每个活动都会扩展。在这种情况下,我希望启动检测以获取有关应用程序的信息:带有startInstrumentation的Android应用程序,android,android-manifest,instrumentation,Android,Android Manifest,Instrumentation,我想从测试的应用程序内部使用接口插入我的应用程序。 我有一个自定义活动,我的每个活动都会扩展。在这种情况下,我希望启动检测以获取有关应用程序的信息: public class BxActivity extends Activity { @Override protected void onResume() { super.onResume(); ... boolean instru = startInstrumentation(new ComponentName(BxAc
public class BxActivity extends Activity {
@Override
protected void onResume() {
super.onResume();
...
boolean instru = startInstrumentation(new ComponentName(BxActivity.this, InstrumentationRobot.class), null, null);
Imho应使用InstrumentationRobot.class中的instrumentation代码重新启动应用程序。它在同一个Android项目和包中
public class InstrumentationRobot extends Instrumentation {
@Override
public void onCreate(Bundle arguments) {
super.onCreate(arguments);
Log.v("InstrRobot", "Hello from Robot");
start();
}
我已将检测添加到清单中,如下所示:
<instrumentation
android:name="InstrumentationRobot" (class in the same pkg)
android:targetPackage="my.package.name" />
</application>
这是正确的指令清单代码,所以我的小机器人向我打印“你好”
谢谢,soeren我找到了解决方案,并用正确的代码更新了我的问题。 错误在清单文件中 我删除了
<uses-library android:name="android.test.runner" />
如果instrumentation类中与应用程序本身位于同一个包和.apk文件中,则标记和instrumentation类名不得以点开头
检测标记还必须是清单的直接子项