Faced the same problem and got the same cricket noises as you. I partially circumvented this problem by refactoring, so that my detected activity is processed in the AsyncTask native class. Then I wrote a series of units that could pass event information to this activity detection processing class. Given that android has a limit on the number of asynchronous operations that can be performed for each object, my junit creates runnables in a loop to interact with the activity processing class.
I also found the otto and dagger2 libraries that can work for inputting events on the android bus. Nevertheless, work continues, although ...
source
share