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.