android - 无法启动 ImplicitTest

标签 android junit

我正在上 coursera android 类(class)。我正在尝试运行第 3 周的实验室,关于 Intents、ImplicitTest,但是当模拟器运行时,它在尝试打开浏览器应用程序时崩溃。并且有一条消息说:“浏览器没有响应”,当我阅读 de Junit 选项卡时,在 Failure Trace 下,它说:ChooserActivity not Found。

如果有人遇到同样的问题,请告诉我如何解决。

这是我的代码:

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>

最佳答案

对于其他任何人来说,都是如此。尝试使用 API 级别 18,如果您使用的是 21/22,您将收到此错误

关于android - 无法启动 ImplicitTest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21745708/

相关文章:

java - 使用mockMvc进行Spring JUnit测试

Android:使用 api 谷歌地图崩溃启动应用程序

java - Android:如何显示相同标签名称的所有 XML 值

java - 游戏测试失败(游戏框架 2.2.2)

java - 输出流持久化问题

java - 如何从java JUnit中的.properties文件获取文件名?

android - 如何通过我的 Android 应用程序与 Pinterest 中的图片共享/固定消息

android - 自定义字体 TextView 的性能问题

android - 什么是 "disable offline mode"和 "disable gradle offline"模式以及 Android Studio 4.1 中的此设置

hibernate - 未配置 CurrentSessionContext! : ThreadLocalSessionContext. 绑定(bind)( session );没有正确绑定(bind)我的 session