Android:尝试在特定设备上发送彩信时偶尔会遇到 ActivityNotFoundException
我正在使用精彩的 ACRA 库来报告用户在我的应用程序测试版中遇到的任何错误。到目前为止所显示的是,一些用户在发送彩信时遇到问题,而大多数用户则没有。 特别是,我发现使用 Droid Bionic 设备的用户遇到了此错误,但当我在本地运行 Droid Bionic 模拟器时,没有遇到问题。 我用来启动彩信活动的代码是...
File imageFile = new File(getContext().getFilesDir() + File.separator + fileName);
Uri uri = Uri.fromFile(imageFile);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
sendIntent.putExtra("sms_body", "");
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
sendIntent.setType("image/png");
getContext().startActivity(sendIntent);
我看到的错误 - 只是偶尔 - 是:
android.content.ActivityNotFoundException:无法找到显式活动类 {com.android.mms/com.android.mms.ui .ComposeMessageActivity};您是否在 AndroidManifest.xml 中声明了此活动?
我怀疑某些运营商可能修改了 Android 并覆盖/禁用了默认的彩信活动。我真的没有一个好的方法来测试这个,因为我亲自测试过的所有物理设备和运营商都没有这个代码的问题。正如我所提到的,Droid Bionic 模拟器工作正常,但它是该领域存在问题的设备之一。
我想知道是否有人经历过类似的事情并有建议的解决方法?或者,如果有人有一种在 Android 上发送彩信的方法,适用于所有设备/运营商。
(现在我只是捕获异常并让用户知道我无法使用他们的设备发送彩信。)
ps 我在另一个论坛中看到有人建议删除意图的类名。问题是,当你这样做时,所有各种类型的应用程序都说它们可以处理意图(例如 Evernote),而事实上我真的只想要彩信或什么都不想要。
I am using the wonderful ACRA library to report any errors that users experience with the beta version of my app. What it has shown so far is that some users experience problems sending MMS messages, while most do not.
In particular I found that a user using a Droid Bionic device experienced this error, but when I run the Droid Bionic emulator locally, I have don't have a problem.
The code I use to start the MMS activity is...
File imageFile = new File(getContext().getFilesDir() + File.separator + fileName);
Uri uri = Uri.fromFile(imageFile);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
sendIntent.putExtra("sms_body", "");
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
sendIntent.setType("image/png");
getContext().startActivity(sendIntent);
The error I see - only very occasionally - is :
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.mms/com.android.mms.ui.ComposeMessageActivity}; have you declared this activity in your AndroidManifest.xml?
My suspicion is that perhaps certain carriers have modified Android and overridden/disabled the default MMS activity. I don't really have a good way of testing this as all the physical devices and carriers I have personally tested it on have no problem with this code. And as I mentioned, the Droid Bionic emulator works fine, but it was one of the devices in the field that had a problem.
I'm wondering if anyone has experienced something similar and has a suggested workaround? Or if someone has a method for sending MMS on Android that works on all devices/carriers.
(For now I am just catching the exception and letting the user know that I couldn't send MMS with their device.)
p.s. I saw in another forum someone suggesting just removing the classname for the intent. The problem with that is when you do that all and sundry types of applications say they can handle the intent (e.g Evernote) when in fact I really just want MMS or nothing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
写下意图
而不是
write down with INTENT
instead of
您可以做...
You can do...