尝试发送MMS时出现以下错误(我抑制了列表中建议的用于编写MMS的应用程序活动),并且代码看起来像
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);
设备:索尼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
请帮我吗?
最佳答案
问题是空指针,如
java.lang.NullPointerException
从您发布的代码看来,路径是问题所在。它正在尝试从堆栈中基于URI设置附件。我怀疑它是否根据您的评论特定于设备。我认为问题仅仅是SDCard上没有“ Page.jpg”。