Question

I am using Robotium for testing android applications and am interested in how to detect a situation when an external application activity (e.g. browser, camera, facebook) is being launched by tested app. There are several questions asking how to handle such situation, but all I need is to detect it, for example just log time when it's occurred. Is this possible using Robotium or simple Instrumentation?

BTW, I can't use the solution when system apps are being replaced by fake analogues, I can't even know what application (and when) will be launched, because the tests are random. (Yes, I know, it's a bad approach, but this is a project restriction).

Was it helpful?

Solution

See my answer here. The main idea is to detect current top Activity, which is Activity of external application. You can create Service, which will monitor top activities.

OTHER TIPS

Anther way is to check when your activity looses focus. When it looses focus that means that the other external Activity has focus instead.

http://developer.android.com/reference/android/app/Activity.html#hasWindowFocus()

You can use Solo.waitForCondition() in conjunction with hasWindowFocus.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top