Android 中的错误 -- 无法找到以下项的检测信息:ComponentInfo
例如,我有一个应用程序将调用联系人并且必须选择其中一个联系人。 但它并没有完全按照我想要的方式做。它向我显示错误无法找到仪器信息:ComponentInfo{com.sample/com.sample.ContactsSelectInstrumentation}
以下是我的代码.. 这是我的活动课
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.go);
button.setOnClickListener(mGoListener);
}
private OnClickListener mGoListener = new OnClickListener() {
public void onClick(View v) {
startInstrumentation(new ComponentName(Test.this,
ContactsFilterInstrumentation.class), null, null);
}
};
这是我的仪器课。
class ContactsFilterInstrumentation extends Instrumentation {
@Override
public void onCreate(Bundle arguments) {
super.onCreate(arguments);
start();
}
@Override
public void onStart() {
super.onStart();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClassName(getTargetContext(), "com.android.phone.Dialer");
Activity activity = startActivitySync(intent);
Log.i("ContactsFilterInstrumentation", "Started: " + activity);
sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_M));
sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_M));
sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_A));
sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_A));
waitForIdleSync();
Log.i("ContactsFilterInstrumentation", "Done!");
finish(Activity.RESULT_OK, null);
}
}
任何人都可以帮助我吗? 提前致谢。
For Example I had an application that will invoke contacts and has to select one of the contact.
But its not doing exactly what I want. It is showing me error Unable to find instrumentation info for: ComponentInfo{com.sample/com.sample.ContactsSelectInstrumentation}
Following is my Code..
This is my Activity class
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.go);
button.setOnClickListener(mGoListener);
}
private OnClickListener mGoListener = new OnClickListener() {
public void onClick(View v) {
startInstrumentation(new ComponentName(Test.this,
ContactsFilterInstrumentation.class), null, null);
}
};
And this is my Intrumentation class.
class ContactsFilterInstrumentation extends Instrumentation {
@Override
public void onCreate(Bundle arguments) {
super.onCreate(arguments);
start();
}
@Override
public void onStart() {
super.onStart();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClassName(getTargetContext(), "com.android.phone.Dialer");
Activity activity = startActivitySync(intent);
Log.i("ContactsFilterInstrumentation", "Started: " + activity);
sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_M));
sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_M));
sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_A));
sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_A));
waitForIdleSync();
Log.i("ContactsFilterInstrumentation", "Done!");
finish(Activity.RESULT_OK, null);
}
}
Can Any help me out.
Thanks in Advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
目录结构应该是:
然后在AndroidManifest.xml中,设置
用命令行调用上面的包:
Directory structure should be:
Then in the AndroidManifest.xml, set
Invoke the above package with the command line:
通过 AndroidManifest.xml 的
标签向系统描述 Instrumentation 实现。An Instrumentation implementation is described to the system through an AndroidManifest.xml's
<instrumentation>
tag.我通过执行以下操作解决了这个问题:
在清单中使用上层包名称:
向下一级实施测试包:
Java文件1:
package com.xxx.yyy.zzz.ptest.onlylogin;
Java 文件 2:
指定如下命令行:
...
I solved this problem by doing the following:
Use a upper-level package name in the manifest:
Implement the test packages one level down:
Java file 1:
package com.xxx.yyy.zzz.ptest.onlylogin;
Java file 2:
Specify the command line like the following:
...