简体   繁体   English

Android:尝试在特定设备上发送MMS时偶尔会遇到ActivityNotFoundException

[英]Android: ActivityNotFoundException occasionally encountered when trying to send MMS on specific devices

I am using the wonderful ACRA library to report any errors that users experience with the beta version of my app. 我正在使用精彩的ACRA库来报告用户使用我的应用测试版所遇到的任何错误。 What it has shown so far is that some users experience problems sending MMS messages, while most do not. 到目前为止它显示的是一些用户在发送MMS消息时遇到问题,而大多数用户没有。 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. 特别是我发现使用Droid Bionic设备的用户遇到了这个错误,但是当我在本地运行Droid Bionic仿真器时,我没有遇到任何问题。 The code I use to start the MMS activity is... 我用来启动MMS活动的代码是......

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}; android.content.ActivityNotFoundException:无法找到显式活动类{com.android.mms / com.android.mms.ui.ComposeMessageActivity}; have you declared this activity in your AndroidManifest.xml? 你有没有在AndroidManifest.xml中声明这个活动?

My suspicion is that perhaps certain carriers have modified Android and overridden/disabled the default MMS activity. 我怀疑是某些运营商可能修改了Android并覆盖/禁用了默认的MMS活动。 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. 正如我所提到的,Droid Bionic仿真器工作正常,但它是该领域中存在问题的设备之一。

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. 或者,如果某人有在Android上发送MMS的方法,该方法适用于所有设备/运营商。

(For now I am just catching the exception and letting the user know that I couldn't send MMS with their device.) (目前我只是抓住异常并让用户知道我无法使用他们的设备发送彩信。)

ps I saw in another forum someone suggesting just removing the classname for the intent. ps我在另一个论坛中看到有人建议只删除意图的类名。 The problem with that is when you do that all and sundry types of applications say they can handle the intent (eg Evernote) when in fact I really just want MMS or nothing. 问题在于,当你这样做时,各种类型的应用程序都表示他们可以处理意图(例如Evernote),而实际上我真的只想要彩信或什么都没有。

write down with INTENT 用INTENT写下来

intent.setPackage("com.android.mms");

instead of 代替

intent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");

You can do... 你可以做...

  1. Keep trying that approach, but catch the ActivityNotFoundException. 继续尝试这种方法,但捕获ActivityNotFoundException。
  2. If you get a ActivityNotFoundException, try to launch other apps that user may have installed (VZMessages, Zlango Messaging, Handcent, ChompSMS, etc). 如果您收到ActivityNotFoundException,请尝试启动用户可能已安装的其他应用程序(VZMessages,Zlango Messaging,Handcent,ChompSMS等)。
  3. If all of them fail, let your user know that you want to send a MMS, and then launch the intent without specifying the class. 如果所有这些都失败了,请让您的用户知道您要发送彩信,然后启动意图而不指定课程。 That way it is up to the users to choose an app that actually send MMS messages. 这样,用户可以选择实际发送MMS消息的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM