android - 如何在 Robotium 中重新启动已关闭的应用程序?

标签 android robotium

我开始自动化我的 Android 应用程序。它有一个“条款和条件”屏幕。这样一来,如果我点击“拒绝”,我的应用程序将被关闭。

如何在同一进程中重新启动或重新启动我的应用程序?

最佳答案

试试这个:

// assuming this method is in a ActivityInstrumentationTestCase2 class
public void test_yourTest() {

    // do your testing

    Solo.sleep(1000);

    // killing all your Activities manually if it doesn't by itself anyway
    Solo.finishOpenedActivities();

    // relaunch your app by calling the same Activity as in the constructor
    // of your ActivityInstrumentationTestCase2
    this.launchActivity(TARGET_PACKAGE_ID, YourStartActivity.class, null);

    Solo.sleep(1000);

    // do your testing
}

关于android - 如何在 Robotium 中重新启动已关闭的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11644288/

相关文章:

android - 状态栏上显示的单行通知?

java - 为什么使用 Uri.Builder

android - 如何使用 ActivityInstrumentationTestCase2 捕获异常?

android - 如何使用 robotium 处理 android 中的外部应用程序 Activity

android - 开始使用 Robotium。未找到编辑文本

java - ListView 中的复选框具有奇怪的检查行为

android - 为什么即使使用视口(viewport)/媒体查询,我的页面也无法在 Android 上以正确的大小显示?

android - 改造可选和必填字段

android - 在 Robotium 中打开 NavigationDrawer 和选择项目的正确方法

javascript - 在 Robotium 中插入 javascript