This code worked on samsung before, but now when I use the Nexus One with Android 2.3.6, it breaks as soon as I take a picture and click ok or select a photo from the gallery. Stacktrace shows a null pointer exception to a Uri.
My code to activate the camera is as follows:
public void activateCamera(View view){ Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // start the image capture Intent startActivityForResult(i, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if ((requestCode == CHOOSE_IMAGE_ACTIVITY_REQUEST_CODE || requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) && resultCode == RESULT_OK && null != data) { 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]); String picturePath = cursor.getString(columnIndex); cursor.close(); Bitmap bits = null; BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = inSampleSize; try { bits = BitmapFactory.decodeStream(new FileInputStream(picturePath),null,options); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); }
Any idea what could be the problem? Thanks!
source share