命令 :
adb shell am instrument -e class com.vishal.nirma.test.MyActivity#MyFunction com.vishal.nirma.test/android.test.InstrumentationTestRunner -e myvar myvalue
现在,
protected void setUp() throws Exception {
getActivity();
super.setUp();
// here i want to receive arguments, which are passed in command line (ex. myvar).
// how to receive arguments here?
}
我正在使用“ ActivityInstrumentationTestCase2 ”。
我在 setup() 中尝试了下面的代码,但它对我不起作用。
Bundle extras = getActivity().getIntent( ).getExtras( );
if ( extras != null )
{
Log.v(TAG,"Parameters Received !!!");
if ( extras.containsKey ( "myvar" ) )
{
String str_myvar = extras.getString ( "myvar" );
} else {
}
}
else
{
Log.v(TAG,"No parameters ???");
}
它总是给我“没有参数???”。
提前感谢您的帮助... :-)