当我尝试发送彩信时出现以下错误(我正在抑制列表建议的应用程序活动以编写彩信)并且我的代码看起来像
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
请帮我解决这个问题?
答案 0 :(得分:0)
问题是空指针,如
所示java.lang.NullPointerException
从您发布的代码看起来路径就是问题所在。从您的堆栈中,它尝试根据URI设置附件。我怀疑它是根据你的评论设备特定的。我认为问题只是“Page.jpg”不在SDCard上。