Open enikey87 opened 9 years ago
Thanks for reporting this.
On Mon, Nov 9, 2015 at 12:01 AM, enikey87 notifications@github.com wrote:
getCurrentActivity() can return wrong one when activity stack changes very fast.
For exampe:
- Start ActivityB where onCreate() is { ... recreate() ... }
- waitForActivity(ActivityB.class). // can return first instance of ActivityB cause of concurrency issues.
- let wrongActivity = solo.getCurrentActivity().
In such cases solo.getCurrentActivity() will never return actual "current".
Reason is following execution chain: [UiThread]: new ActivityB.onCreate(). [Instrumentation]: Instrumentation.performOnCreate() { ... monitors.match(old Activity) } [UiThread]: old ActivityB.onDestroy(). [Instrumentation]: Instrumentation.performOnDestroy() { ... monitors.match(new Activity) } [ActivityMonitorThread]: waitForActivity() returns destroyed "old ActivityB" and "new ActivityB" is now lost forever.
— Reply to this email directly or view it on GitHub https://github.com/RobotiumTech/robotium/issues/796.
I am experiencing the same problem. But for me this is consistently reproducing when I enable "Don't Keep Activities" in Developer options iin the test device. If I disable the dev option. Its working fine for me..
FYI ActivityLifecycleCallbacks can be used as workaround for this issue
getCurrentActivity() can return wrong one when activity stack changes very fast.
For exampe:
In such cases solo.getCurrentActivity() will never return actual "current".
Reason is following execution chain: