问题
Is there any way to check whether an android application got closed and returned to device application list using robotium?
回答1:
There is no direct way, however two ideas came to my mind. First:
private boolean isApplicationClosed() {
return solo.getCurrentViews().size() == 0;
}
Second (this may affect your application):
private boolean isApplicationClosed() {
try {
solo.clickOnScreen(100, 100);
} catch (AssertionFailedError e) {
if("Click can not be completed!".equals(e.getMessage().trim()) {
return true;
}
}
return false;
}
来源:https://stackoverflow.com/questions/19808599/how-to-check-if-an-application-got-closed-and-returned-to-device-application-lis