1

(A) App to test (eg. Browser)

(B) Test app. (extends ActivityInstrumentationTestCase2) (Robotium)

(C) Launcher (like "devTools" -> Instrumentation)

How can I create an APK(C) that can launch the Test app(B).

quiel
  • 427
  • 1
  • 3
  • 19

1 Answers1

2
public class Main extends Activity {

protected List<InstrumentationInfo> mList;
protected ComponentName mBrowserTestComponent;
protected final static String TARGET_PACKAGE = "com.android.browser";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mList = this.getPackageManager().queryInstrumentation(TARGET_PACKAGE, 0);
    mBrowserTestComponent = instrumentationForPosition(0);
}

public void startTesting(View view) {
    this.startInstrumentation(mBrowserTestComponent, null, null);
}

public ComponentName instrumentationForPosition(int position)
{
    if (mList == null) {
        return null;
    }
    InstrumentationInfo ii = mList.get(position);
    return new ComponentName(ii.packageName, ii.name);
}
}
quiel
  • 427
  • 1
  • 3
  • 19
  • Reference: https://github.com/android/platform_development/blob/master/apps/Development/src/com/android/development/InstrumentationList.java – quiel Mar 22 '12 at 01:04