Getting Image URI issues

All your problems with Audio, Video and Images.

Getting Image URI issues

Postby althejandro » Sat Mar 26, 2011 12:38 am

I'm trying to launch a camera intent, take a picture, and then get the URI of the image and pass that to another activity.

Right now i'm getting an FC because when I try to get the URI from the image there is a nullPointerException
Any suggestions on what i'm doing wrong? FYI - I'm kinda a nooblet


This is where I'm launching the camera
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. String fileName = "temp.jpg";  
  2. ContentValues values = new ContentValues();  
  3. values.put(MediaStore.Images.Media.TITLE, fileName);  
  4. Uri mCapturedImageURI = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);  
  5.  
  6. Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);  
  7. intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI);  
  8. startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
  9.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4



Dealing With Pic
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. protected void onActivityResult(int requestCode, int resultCode, Intent data)
  2.         {
  3.  
  4.             //ERROR IS HERE
  5.             Uri takenImage = data.getData();
  6.                
  7.             String[] projection = { MediaStore.Images.Media.DATA};
  8.             Cursor cursor = managedQuery(takenImage, projection, null, null, null);
  9.             int column_index_data = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
  10.             cursor.moveToFirst();
  11.             String img_path = cursor.getString(column_index_data);
  12.                
  13.             Intent handleNewPic = new Intent(takePic.this, HandlePic.class);
  14.             Bundle bundle = new Bundle();
  15.             bundle.putString("picturePath", img_path);
  16.             handleNewPic.putExtras(bundle);
  17.                
  18.  
  19.             startActivity(handleNewPic);
  20.         }
  21.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
althejandro
Freshman
Freshman
 
Posts: 3
Joined: Sun May 30, 2010 5:57 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 14 guests