指示 :
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 ???");
}
常に「パラメーターがありません???」と表示されます。
事前にご協力いただきありがとうございます... :-)