启动android.intent.action.VIEW时出现ActivityNotFoundException [英] ActivityNotFoundException when starting android.intent.action.VIEW

查看:668
本文介绍了启动android.intent.action.VIEW时出现ActivityNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行context.startActivity(intent);,我的意图如下:

I am running context.startActivity(intent); and my intent looks like this:

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.setDataAndType(Uri.parse(uri), mimeType);

此时的

uri是一个字符串http://remote.server.path/photo-12212324324.jpg

,mimeType为image/jpeg

and mimeType is image/jpeg

这是例外的一个例子.

12-07 20:48:55.934: I/ActivityManager(633): START u0 {act=android.intent.action.VIEW dat=http: typ=image/jpeg flg=0x1} from pid 1414
12-07 20:48:55.964: W/dalvikvm(1414): threadid=1: thread exiting with uncaught exception (group=0x40cb5ba0)
12-07 20:48:56.034: E/AndroidRuntime(1414): FATAL EXCEPTION: main
12-07 20:48:56.034: E/AndroidRuntime(1414): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http: typ=image/jpeg flg=0x1 }
12-07 20:48:56.034: E/AndroidRuntime(1414):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1760)
12-07 20:48:56.034: E/AndroidRuntime(1414):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1555)
12-07 20:48:56.034: E/AndroidRuntime(1414):     at android.app.Activity.startActivityForResult(Activity.java:3431)

这种情况至少发生在该领域的两台设备上,其中一台是Samsung Galaxy S5,因此,我怀疑没有应用程序可以处理此意图,因为用户将至少安装了Samsung Gallery应用程序.我可以处理异常并显示错误,但这并不是真正的解决方法.

This happens on at least two devices in the field, one of which is Samsung Galaxy S5, and therefore, I doubt that there's no app to handle the intent as the user will have at least Samsung Gallery app installed.. I know I can just handle the exception and show an error, but that's not really a fix..

推荐答案

我正在运行context.startActivity(intent);而我的意图是这样的:

I am running context.startActivity(intent); and my intent looks like this:

嗯,FLAG_GRANT_READ_URI_PERMISSION在这里没用.仅当您的Uri来自ContentProvider时.

Um, FLAG_GRANT_READ_URI_PERMISSION is useless here. That is only for when your Uri is coming from a ContentProvider.

我怀疑没有应用程序可以处理此意图,因为用户将至少安装了Samsung Gallery应用程序

I doubt that there's no app to handle the intent as the user will have at least Samsung Gallery app installed

设备可能具有该应用. 用户可能不会.请记住,在Android 4.2+平板电脑和Android 5.0+手机上,一台设备可能有多个用户.其中一些用户可能是受限帐户",他们只能访问白名单中的一组应用程序.

The device may have that app. The user may not. Please bear in mind that on Android 4.2+ tablets and Android 5.0+ phones, a device may have multiple users. Some of those users may be "restricted accounts", where they have access only to a whitelisted set of apps.

请不要假定所有用户都可以访问可以下载和查看图像的应用程序.

Please do not assume that all users will have access to an app that can download and view images.

此外,我不认为任何三星图库应用"都一定会支持http作为方案.

Also, I would not assume that whatever "Samsung Gallery app" is will necessarily support http as a scheme.

我知道我可以处理异常并显示错误,但这并不是真正的解决方法

I know I can just handle the exception and show an error, but that's not really a fix

如果您不想显示错误,请使用自己的图片查看器作为后备广告.

Implement your own image viewer as a fallback, if you do not want to show an error.

这篇关于启动android.intent.action.VIEW时出现ActivityNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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