I try to get picture from android camera using this code but I will get error would you please helping me in this implementation,Thanks in advance
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
//try{
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SELECT_IMAGE)
if (resultCode == Activity.RESULT_OK && null != data) {
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
Log.d("filecolumn : ",filePathColumn.toString());
String picturePath = cursor.getString(columnIndex);
cursor.close();
Intent i = new Intent(getApplicationContext(), CustomizeActivity.class);
i.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
mCurrentPhotoPath);
i.putExtra("type", "album");
i.putExtra("photo", picturePath);
Log.d("getPath : ",picturePath);
startActivity(i);
overridePendingTransition( R.anim.slide_in_left, R.anim.slide_out_left );
Log.d("photo : ",selectedImage.getPath());
// TODO Do something with the select image URI
}
if(requestCode == CAMERA_PIC_REQUEST)
{
Log.v("camera", "cam");
if (resultCode == Activity.RESULT_OK) {
Log.v("camera", "result ok");
Intent i = new Intent(getApplicationContext(), CustomizeActivity.class);
i.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
mCurrentPhotoPath);
i.putExtra("type", "photo");
i.putExtra("photo", mCurrentPhotoPath);
startActivity(i);
overridePendingTransition( R.anim.slide_in_left, R.anim.slide_out_left );
}
}
}
error log:
01-22 15:53:55.375: D/szipinf(810): Initializing inflate state
01-22 15:53:55.386: V/photo path(810): photoPath : null
01-22 15:53:55.386: W/System.err(810): java.lang.NullPointerException: file == null
01-22 15:53:55.386: W/System.err(810): at java.io.FileInputStream.<init>(FileInputStream.java:76)
01-22 15:53:55.386: W/System.err(810): at java.io.FileInputStream.<init>(FileInputStream.java:132)
01-22 15:53:55.386: W/System.err(810): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:362)
01-22 15:53:55.386: W/System.err(810): at com.odacia.appcarnaval.CustomizeActivity.onCreate(CustomizeActivity.java:181)
01-22 15:53:55.386: W/System.err(810): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-22 15:53:55.386: W/System.err(810): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
android.intent.action.MEDIA_UNMOUNTED