Why does getActivity() block during JUnit test when custom ImageView calls startAnimation(Animation)?
问题 I wrote an Android app that displays a custom ImageView that rotates itself periodically, using startAnimation(Animation) . The app works fine, but if I create a JUnit test of type ActivityInstrumentationTestCase2 and the test calls getActivity() , that call to getActivity() never returns until the app goes to the background (for example, the device's home button is pressed). After much time and frustration, I found that getActivity() returns immediately if I comment out the call to