使用 com.android.mms.ui.ComposeMessageActivity 发送彩信时出错
当我尝试发送彩信时出现以下错误(我正在抑制用于编写彩信的建议应用程序活动列表),并且我的代码类似于
Uri path = Uri.parse("file:///sdcard//page.jpg");
Intent intent = new Intent(Intent.ACTION_SEND, path);
intent.putExtra("address", “<<phone number>>”);
intent.putExtra("subject", "dfsdfsdfds");
intent.putExtra("sms_body", "hello");
intent.setClassName(
"com.android.mms",
"com.android.mms.ui.ComposeMessageActivity"
);
intent.putExtra(Intent.EXTRA_STREAM, path);
intent.setType("image/*");
startActivity(intent);
设备:Sony Xperia SDK版本:2.1
ERROR/AndroidRuntime(2205): FATAL EXCEPTION: main
ERROR/AndroidRuntime(2205): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.mms/com.android.mms.ui.ComposeMessageActivity}: java.lang.NullPointerException
ERROR/AndroidRuntime(2205): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
ERROR/AndroidRuntime(2205): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
ERROR/AndroidRuntime(2205): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
ERROR/AndroidRuntime(2205): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
ERROR/AndroidRuntime(2205): at android.os.Handler.dispatchMessage(Handler.java:99)
ERROR/AndroidRuntime(2205): at android.os.Looper.loop(Looper.java:123)
ERROR/AndroidRuntime(2205): at android.app.ActivityThread.main(ActivityThread.java:4627)
ERROR/AndroidRuntime(2205): at java.lang.reflect.Method.invokeNative(Native Method)
ERROR/AndroidRuntime(2205): at java.lang.reflect.Method.invoke(Method.java:521)
ERROR/AndroidRuntime(2205): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
ERROR/AndroidRuntime(2205): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
ERROR/AndroidRuntime(2205): at dalvik.system.NativeStart.main(Native Method)
ERROR/AndroidRuntime(2205): Caused by: java.lang.NullPointerException
ERROR/AndroidRuntime(2205): at com.android.mms.ui.UriImage.(UriImage.java:68)
ERROR/AndroidRuntime(2205): at com.android.mms.model.ImageModel.initModelFromUri(ImageModel.java:82)
ERROR/AndroidRuntime(2205): at com.android.mms.model.ImageModel.(ImageModel.java:64)
ERROR/AndroidRuntime(2205): at com.android.mms.data.WorkingMessage.changeMedia(WorkingMessage.java:461)
ERROR/AndroidRuntime(2205): at com.android.mms.data.WorkingMessage.setAttachment(WorkingMessage.java:362)
ERROR/AndroidRuntime(2205): at com.android.mms.ui.ComposeMessageActivity.addImage(ComposeMessageActivity.java:2640)
ERROR/AndroidRuntime(2205): at com.android.mms.ui.ComposeMessageActivity.addAttachment(ComposeMessageActivity.java:2776)
ERROR/AndroidRuntime(2205): at com.android.mms.ui.ComposeMessageActivity.handleSendIntent(ComposeMessageActivity.java:2705)
ERROR/AndroidRuntime(2205): at com.android.mms.ui.ComposeMessageActivity.initialize(ComposeMessageActivity.java:1743)
ERROR/AndroidRuntime(2205): at com.android.mms.ui.ComposeMessageActivity.onCreate(ComposeMessageActivity.java:1678)
ERROR/AndroidRuntime(2205): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
ERROR/AndroidRuntime(2205): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
ERROR/AndroidRuntime(2205): ... 11 more
请帮我解决这个问题?
I am getting following error when I try to send an MMS (I am suppressing the list suggested application activity for composing the MMS) and my code looks like
Uri path = Uri.parse("file:///sdcard//page.jpg");
Intent intent = new Intent(Intent.ACTION_SEND, path);
intent.putExtra("address", “<<phone number>>”);
intent.putExtra("subject", "dfsdfsdfds");
intent.putExtra("sms_body", "hello");
intent.setClassName(
"com.android.mms",
"com.android.mms.ui.ComposeMessageActivity"
);
intent.putExtra(Intent.EXTRA_STREAM, path);
intent.setType("image/*");
startActivity(intent);
Device: Sony Xperia
SDK version: 2.1
ERROR/AndroidRuntime(2205): FATAL EXCEPTION: main
ERROR/AndroidRuntime(2205): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.mms/com.android.mms.ui.ComposeMessageActivity}: java.lang.NullPointerException
ERROR/AndroidRuntime(2205): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
ERROR/AndroidRuntime(2205): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
ERROR/AndroidRuntime(2205): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
ERROR/AndroidRuntime(2205): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
ERROR/AndroidRuntime(2205): at android.os.Handler.dispatchMessage(Handler.java:99)
ERROR/AndroidRuntime(2205): at android.os.Looper.loop(Looper.java:123)
ERROR/AndroidRuntime(2205): at android.app.ActivityThread.main(ActivityThread.java:4627)
ERROR/AndroidRuntime(2205): at java.lang.reflect.Method.invokeNative(Native Method)
ERROR/AndroidRuntime(2205): at java.lang.reflect.Method.invoke(Method.java:521)
ERROR/AndroidRuntime(2205): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
ERROR/AndroidRuntime(2205): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
ERROR/AndroidRuntime(2205): at dalvik.system.NativeStart.main(Native Method)
ERROR/AndroidRuntime(2205): Caused by: java.lang.NullPointerException
ERROR/AndroidRuntime(2205): at com.android.mms.ui.UriImage.(UriImage.java:68)
ERROR/AndroidRuntime(2205): at com.android.mms.model.ImageModel.initModelFromUri(ImageModel.java:82)
ERROR/AndroidRuntime(2205): at com.android.mms.model.ImageModel.(ImageModel.java:64)
ERROR/AndroidRuntime(2205): at com.android.mms.data.WorkingMessage.changeMedia(WorkingMessage.java:461)
ERROR/AndroidRuntime(2205): at com.android.mms.data.WorkingMessage.setAttachment(WorkingMessage.java:362)
ERROR/AndroidRuntime(2205): at com.android.mms.ui.ComposeMessageActivity.addImage(ComposeMessageActivity.java:2640)
ERROR/AndroidRuntime(2205): at com.android.mms.ui.ComposeMessageActivity.addAttachment(ComposeMessageActivity.java:2776)
ERROR/AndroidRuntime(2205): at com.android.mms.ui.ComposeMessageActivity.handleSendIntent(ComposeMessageActivity.java:2705)
ERROR/AndroidRuntime(2205): at com.android.mms.ui.ComposeMessageActivity.initialize(ComposeMessageActivity.java:1743)
ERROR/AndroidRuntime(2205): at com.android.mms.ui.ComposeMessageActivity.onCreate(ComposeMessageActivity.java:1678)
ERROR/AndroidRuntime(2205): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
ERROR/AndroidRuntime(2205): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
ERROR/AndroidRuntime(2205): ... 11 more
Please help me out on this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是空指针,如
您发布的代码所示,看起来路径是问题所在。从您的堆栈中,它尝试根据 URI 设置附件。根据您的评论,我怀疑它是特定于设备的。我认为问题很简单,“Page.jpg”不在 SDCard 上。
The problem is a null pointer as indicated by
From the code you have posted it looks like path is the problem. From your stack it is trying to set the attachment based on the URI. I doubt it is device specific as per your comment. I think the problem is simply that "Page.jpg" is not on the SDCard.