Getting Nullpointer Exception On Capturing Video From Camera, Android?
I tested my code on sony, samsung and HTC devices where it works fine. But it doesnt work on other devices like karbonn etc... Here is my code Intent intent = new Intent(MediaS
Solution 1:
The fileUri
already has the Uri of the file. Try removing the cursor part and using the following instead:
FilenewFile=newFile(videoUri.getPath());
StringfilePath= newFile.getAbsolutePath();
Please let me know if this works.
Solution 2:
Try this..
change the below line
Cursorcursor= getContentResolver().query(fileUri, proj,
null, null, null);
as
Cursorcursor= getContentResolver().query(videoUri, proj,
null, null, null);
because your Uri path assigned as like this Uri videoUri = fileUri;
then your added in cursor as fileUri
EDIT:
try {
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(videoUri, proj,
null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(proj[0]);
filePath = cursor.getString(columnIndex);
} catch (Exception e) {
filePath = videoUri.getPath();
}
Log.v("log", "filePath is : " + filePath);
Solution 3:
Try like below
UrivideoUri= data.getData();//Changed here
String[] proj = { MediaStore.Video.Media.DATA };//Changed HereCursorcursor= getContentResolver().query(videoUri, proj,
null, null, null);
Post a Comment for "Getting Nullpointer Exception On Capturing Video From Camera, Android?"