【问题标题】:Testing Main/Launcher Activity in Android在 Android 中测试 Main/Launcher Activity
【发布时间】:2015-09-23 06:46:40
【问题描述】:

我们正在开发一个以 LoginActivity 作为主要活动的应用程序,但在开发过程中,我们配置了下一个活动以避免每次都写入用户/密码。我从 TDD 开始,为了避免错误的活动,我正在尝试创建一个简单的测试来检查它。

有没有办法创建一个测试来检查用户点击应用程序图标时调用了什么活动?我尝试过使用 ActivityInstrumentationTestCase2,但它只能让我选择要测试的活动,而不是完整的应用程序。

谢谢

【问题讨论】:

    标签: android testing android-activity


    【解决方案1】:

    我不确定具体问的是什么,但您的应用程序的启动意图可以通过以下方式获得:

    getPackageManager().getLaunchIntentForPackage(context.getPackageName())
    

    参见例如Get the launcher Activity name of an android application

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-18
      • 2012-12-18
      • 1970-01-01
      • 2011-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多