无法启动ImplicitTest

时间:2014-02-13 05:07:17

标签: android junit

我正在使用android课程。我正在尝试运行第3周Lab,关于Intents,ImplicitTest但是当模拟器运行时,它会在尝试打开浏览器应用程序时崩溃。并且有一条消息说:“浏览器没有响应”,当我读取de Junit Tab时,在Failure Trace下,它说:找不到ChooserActivity。

如果有人遇到同样的问题,请告诉我如何修复它。

这是我的代码:

private void startImplicitActivation() {

        Log.i(TAG, "Entered startImplicitActivation()");

        // TODO - Create a base intent for viewing a URL 
        // (HINT:  second parameter uses parse() from the Uri class)
        Uri pagina = Uri.parse(URL);
        Intent pag = new Intent(Intent.ACTION_VIEW,pagina);


        // TODO - Create a chooser intent, for choosing which Activity
        // will carry out the baseIntent. Store the Intent in the 
        // chooserIntent variable below. HINT: using the Intent class' 
        // createChooser())

        Intent chooserIntent = null;
        chooserIntent= Intent.createChooser(pag,CHOOSER_TEXT);

        Log.i(TAG,"Chooser Intent Action:" + chooserIntent.getAction());
        // TODO - Start the chooser Activity, using the chooser intent
        startActivity(chooserIntent);

    }

这部分是MyBrowser Manifest

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="http" />
</intent-filter>

4 个答案:

答案 0 :(得分:4)

对于任何其他人堆叠在此。尝试使用API​​级别18,如果您使用的是21/22,则会收到此错误

答案 1 :(得分:1)

我有同样的问题。在我将模拟器更改为具有200 MB的SD卡后,浏览器确实可以正常工作。

在实际运行测试用例之前,您可能需要首先检查并确保浏览器应用程序正常运行。

答案 2 :(得分:0)

我使用以下内容获得了正确的工作版本:

<intent-filter>
    <!-- REMOVE VIEW -->
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="http" />
</intent-filter>

答案 3 :(得分:0)

在我的情况下,我有一个默认浏览器,一个Opera Mini和一个My Browser应用程序。正如我们给出了Robotium测试用例,讲师提供的方法是

solo.clickInList(2, 0);

我们必须根据它的显示方式进行更改,因为要单击列表的第一项,请使用clickInList(1)而不是clickInList(0)。其次,点击是相对于屏幕上的可见项目,因此clickInList(1)将单击列表中的第一个可见项目,而不是整个第一个项目。

如实验表pdf文件所示,教授有两个列表,它与

一起使用
solo.clickInlist(2,0);

但在我的情况下,它可以使用,

solo.clickInList(1,1);

虽然它实际上没有奏效,但测试用例成功运行。

相关问题