在Android的--Unable错误找仪器信息为:ComponentInfo [英] Error in Android --Unable to find instrumentation info for: ComponentInfo

查看:224
本文介绍了在Android的--Unable错误找仪器信息为:ComponentInfo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如我不得不将调用联系,并选择一个联系的应用程序。
但它没有这样做正是我想要的。它显示了我的错误无法找到仪器仪表信息:ComponentInfo {com.sample / com.sample.ContactsSelectInstrumentation}

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}

以下是我的code ..
这是我的Activity类

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

这是我Intrumentation类。

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.

推荐答案

目录结构应该是:

src
  package.x.y.z.test
      MainTest.java
      CustomInstrumentationRunner.java

然后在AndroidManifest.xml中,设置

Then in the AndroidManifest.xml, set

<manifest package="package.x.y.z" ...

<instrumentation
        android:name="package.x.y.z.test.CustomInstrumentationRunner"

在命令行调用以上套餐:

Invoke the above package with the command line:

adb shell am instrumentation -w package.x.y.z/package.x.y.z.test.CustomInstrumentationRunner

这篇关于在Android的--Unable错误找仪器信息为:ComponentInfo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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