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.Me开发者_StackOverflowthod.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 ?
The problem is a null pointer as indicated by
java.lang.NullPointerException
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.
精彩评论