使用内容uri和android 4.3 jelly bean时遇到问题(API级别18) 这是我用来在设备上打开相机并录制视频的代码
完成录制并尝试保存我的视频后,显示我不幸停止了,任何解决方案
注意:我在logcat(第241行)中的问题行代码从此代码开始
mVideoURI = data.getData();
这是我的NullPointerException问题
if (requestCode == VIDEO_CAPTURE && resultCode == RESULT_OK) {
mVideoURI = data.getData();
MediaMetadataRetriever mb = new MediaMetadataRetriever();
mb.setDataSource(mVideoPath);
Bitmap image = mb.getFrameAtTime();
if (image != null) {
messageList.add(new Message(mVideoURI, time, R.drawable.msg_status_gray_waiting, state, msgStatutSend, image));
updateAdapter();
}
}
这是我的 logcat
04-01 17:57:03.384 16263-16263/com.example.android.task4 E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=101, result=-1, data=null} to activity {com.example.android.task4/com.example.android.task4.Main2ActivityChat}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:3510)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3553)
at android.app.ActivityThread.access$1200(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1374)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5455)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.android.task4.Main2ActivityChat.onActivityResult(Main2ActivityChat.java:241)
at android.app.Activity.dispatchActivityResult(Activity.java:5563)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3506)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3553)
at android.app.ActivityThread.access$1200(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1374)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5455)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
at dalvik.system.NativeStart.main(Native Method)