Wait for UI thread to finish
android, android-testing, multithreading
Solution
just do one thing No call for super(). I think its Bug on API Level > 11.
@Override
protected void onSaveInstanceState(Bundle outState) {
//No call for super(). Bug on API Level > 11.
}
or
If you need to save the instance, and add something to your outState Bundle you can use the following :
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putString("WORKAROUND_FOR_BUG_19917_KEY", "WORKAROUND_FOR_BUG_19917_VALUE");
super.onSaveInstanceState(outState);
}
Hope it will solve your problem. Goood luck :)
Problem
I am running an instrumentation Activity test. In that I need to perform some UI operations in one of the UI elements of the Activity. So I am doing this in the UI thread of the Activity like this: ``` settingsActivity.runOnUiThread(new Runnable() { @Override public void run() { testSwitch.performClick(); } }); ``` Every time I am hit by `can not perform this action after onSaveInstanceState` whenever the perform click is called. A couple of things I have done: - I have tried putting `Thread.sleep()` after the code but it is not working. - I am not finishing the activity in the tear down. So, I don't know how the Activity is getting destroyed. Cheers, Saurav