I created such an application. The button has a button, when you click the button, video capture starts.
I now have this code for this: -
public class VideoCaptureComponentActivity extends Activity implements View.OnClickListener { VideoView vv; ImageButton ib; TextView tv; Intent i; final static int cameraData=0; File path = null; Uri myVideo; private static final int CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE = 200; private Uri fileUri; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); vv= (VideoView) findViewById(R.id.vvVideoCapture); ib=(ImageButton) findViewById(R.id.btnVideo); ib.setOnClickListener(this); tv= (TextView) findViewById(R.id.tvFilePath); } @Override public void onClick(View v) { switch(v.getId()) { case R.id.btnVideo: Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); fileUri = getOutputMediaFileUri();
Now after I captured the video, the application crashes.
07-06 17:12:09.447: E/AndroidRuntime(2917): FATAL EXCEPTION: main 07-06 17:12:09.447: E/AndroidRuntime(2917): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=200, result=-1, data=Intent { }} to activity {com.optimus.mobile.survey/com.optimus.mobile.survey.VideoCaptureComponentActivity}: java.lang.NullPointerException 07-06 17:12:09.447: E/AndroidRuntime(2917): at android.app.ActivityThread.deliverResults(ActivityThread.java:3712) 07-06 17:12:09.447: E/AndroidRuntime(2917): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3754) 07-06 17:12:09.447: E/AndroidRuntime(2917): at android.app.ActivityThread.access$2800(ActivityThread.java:135) 07-06 17:12:09.447: E/AndroidRuntime(2917): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2162) 07-06 17:12:09.447: E/AndroidRuntime(2917): at android.os.Handler.dispatchMessage(Handler.java:99) 07-06 17:12:09.447: E/AndroidRuntime(2917): at android.os.Looper.loop(Looper.java:143) 07-06 17:12:09.447: E/AndroidRuntime(2917): at android.app.ActivityThread.main(ActivityThread.java:4914) 07-06 17:12:09.447: E/AndroidRuntime(2917): at java.lang.reflect.Method.invokeNative(Native Method) 07-06 17:12:09.447: E/AndroidRuntime(2917): at java.lang.reflect.Method.invoke(Method.java:521) 07-06 17:12:09.447: E/AndroidRuntime(2917): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) 07-06 17:12:09.447: E/AndroidRuntime(2917): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 07-06 17:12:09.447: E/AndroidRuntime(2917): at dalvik.system.NativeStart.main(Native Method) 07-06 17:12:09.447: E/AndroidRuntime(2917): Caused by: java.lang.NullPointerException 07-06 17:12:09.447: E/AndroidRuntime(2917): at com.optimus.mobile.survey.VideoCaptureComponentActivity.onActivityResult(VideoCaptureComponentActivity.java:82) 07-06 17:12:09.447: E/AndroidRuntime(2917): at android.app.Activity.dispatchActivityResult(Activity.java:3931) 07-06 17:12:09.447: E/AndroidRuntime(2917): at android.app.ActivityThread.deliverResults(ActivityThread.java:3708) 07-06 17:12:09.447: E/AndroidRuntime(2917): ... 11 more
basically the problem is that in the code
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); fileUri = getOutputMediaFileUri(); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
here it doesnβt save the file in the set location, I donβt know what the problem is. I took this code from this link http://developer.android.com/guide/topics/media/camera.html
source share