如何检查,如果一个应用程序得到了封闭,并使用robotium返回到设备应用程序列表? [英] How to check if an application got closed and returned to device application list using robotium?

查看:111
本文介绍了如何检查,如果一个应用程序得到了封闭,并使用robotium返回到设备应用程序列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法来检查一个Android应用程序是否得到了关闭,并使用robotium返回到设备应用程序列表?

Is there any way to check whether an android application got closed and returned to device application list using robotium?

推荐答案

有没有直接的方法,但两个想法来到我的脑海里。 第一:

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;
}

这篇关于如何检查,如果一个应用程序得到了封闭,并使用robotium返回到设备应用程序列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆