How to check if an application got closed and returned to device application list using robotium?

被刻印的时光 ゝ 提交于 2019-12-13 04:40:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!