Dear All,

I am working on an application that takes a Photo or a Video, saves it to the mobile and then allows the user to upload it to a local server using HTTP posted requests.

What will make me go crazy is that Pictures works well while Video capturing have some problems although i am using almost the same strategies for both cases, the problem is that : putExtra() methods don't work well in the case of Video capturing, after closing Camera and getting back to my activity, the specified URI is lost, and regarding the other values:EXTRA_VIDEO_QUALITY and EXTRA_DURATION_LIMIT, they change the application behaviour when used but not to the expected behaviour!

Here is the used code:
Code:
 
// create Intent to capture the video and return control to the calling application
	        	    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
	        	    fileUri = getOutputMediaFileUri2(MEDIA_TYPE_VIDEO); // create a file to save the image
	        	    intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the video file name
	        	    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); // set the video quality to high if 1
	        	    intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 40000);//duration
	        	    //intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 5000);// Specify the maximum allowed size. 
	        	    // start the image capture Intent
	        	    startActivityForResult(intent, CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);
When Result is come back to the application, i use the following code:
Code:
  
// Video captured and saved to fileUri specified in the Intent
	        	 mVideoCaptureUri = data.getData();
	        	 String path = getRealPathFromURI(mVideoCaptureUri,MEDIA_TYPE_VIDEO); //from Gallery
	        	 if (path == null)
	        	 path = mVideoCaptureUri.getPath(); //from File Manager
And in the logging i get:

Code:
//before capturing the video, this value is restored from the Intent Object after setting it:
05-07 09:54:59.119: D/INTENT CONTENT BEFORE(19689): file:///mnt/sdcard/MyCameraApp/VID_20120507_095459.mp4
//Just after coming back to the Activity
05-07 09:55:10.809: D/INTENT CONTENT After result(19689): content://media/external/video/media/56
//After calling the function getRealPathFromURI()
05-07 09:55:10.839: D/INTENT CONTENT After getRealPathFromURI(19689): /mnt/sdcard/DCIM/100ANDRO/MOV_0233.3gp


Here is the implementation of the function getRealPathFromURI()
Code:
	   
   public String getRealPathFromURI(Uri contentUri, int type) {
	   Cursor cursor;
	   if (type == MEDIA_TYPE_IMAGE){
		   String [] proj		=	{MediaStore.Images.Media.DATA};
		   cursor		=	managedQuery( contentUri, proj, null, null,null);
	     } else if(type == MEDIA_TYPE_VIDEO) {
	       String [] proj		=	{MediaStore.Video.Media.DATA};
	       cursor		=	managedQuery( contentUri, proj, null, null,null);
	     } else {
	         return null;
	   }
	  	  
	   if (cursor == null) return null;
       
       //int column_index    = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
       int column_index = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA); 
       cursor.moveToFirst(); 
       
       return cursor.getString(column_index);
   }
I would be thankful for any help!