Problem Capturing an Image with Camera

All your problems with Audio, Video and Images.

Problem Capturing an Image with Camera

Postby xil3 » Sun Apr 11, 2010 8:21 pm

The problem is that it's not copying the image at the selected path.

Here is the error:

20:19:00.671 1437 ERROR ReceiptWallet Cannot load image
20:19:00.671 1437 ERROR ReceiptWallet java.lang.NullPointerException
20:19:00.671 1437 ERROR ReceiptWallet at org.xil3.receiptwallet.Receipt.onActivityResult(Receipt.java:102)
20:19:00.671 1437 ERROR ReceiptWallet at android.app.Activity.dispatchActivityResult(Activity.java:3828)
20:19:00.671 1437 ERROR ReceiptWallet at android.app.ActivityThread.deliverResults(ActivityThread.java:3325)
20:19:00.671 1437 ERROR ReceiptWallet at android.app.ActivityThread.handleSendResult(ActivityThread.java:3371)
20:19:00.671 1437 ERROR ReceiptWallet at android.app.ActivityThread.access$2700(ActivityThread.java:119)
20:19:00.671 1437 ERROR ReceiptWallet at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1893)
20:19:00.671 1437 ERROR ReceiptWallet at android.os.Handler.dispatchMessage(Handler.java:99)
20:19:00.671 1437 ERROR ReceiptWallet at android.os.Looper.loop(Looper.java:123)
20:19:00.671 1437 ERROR ReceiptWallet at android.app.ActivityThread.main(ActivityThread.java:4363)
20:19:00.671 1437 ERROR ReceiptWallet at java.lang.reflect.Method.invokeNative(Native Method)
20:19:00.671 1437 ERROR ReceiptWallet at java.lang.reflect.Method.invoke(Method.java:521)
20:19:00.671 1437 ERROR ReceiptWallet at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
20:19:00.671 1437 ERROR ReceiptWallet at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
20:19:00.671 1437 ERROR ReceiptWallet at dalvik.system.NativeStart.main(Native Method)


Here is my code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private void saveFullPicture() {
  2.  
  3.     Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  4.  
  5.     File file = new File(Environment.getExternalStorageDirectory(), String.valueOf(System.currentTimeMillis()) + ".jpg");
  6.  
  7.  
  8.  
  9.     outputFileUri = Uri.fromFile(file);
  10.  
  11.     intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
  12.  
  13.     startActivityForResult(intent, TAKE_PICTURE);
  14.  
  15.   }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2.  
  3.   protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  4.  
  5.     Log.v( "ReceiptWallet", "resultCode: " + resultCode );
  6.  
  7.     switch( resultCode ) {
  8.  
  9.       case 0:
  10.  
  11.         Log.v("ReceiptWallet", "User cancelled");
  12.  
  13.         break;
  14.  
  15.  
  16.  
  17.       case -1:
  18.  
  19.         try {
  20.  
  21.           BitmapFactory.Options options = new BitmapFactory.Options();
  22.  
  23.           options.inSampleSize = 4;
  24.  
  25.  
  26.  
  27.           Bitmap bitmap = BitmapFactory.decodeFile(outputFileUri.getPath(), options);
  28.  
  29.           mIv.setImageBitmap(bitmap);
  30.  
  31.         } catch(Exception e) {
  32.  
  33.           Log.e("ReceiptWallet", "Cannot load image", e);
  34.  
  35.         }
  36.  
  37.         break;
  38.  
  39.     }
  40.  
  41.   }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
[code]
xil3
Freshman
Freshman
 
Posts: 5
Joined: Sun Apr 11, 2010 8:13 pm

Top

Postby xil3 » Mon Apr 12, 2010 10:36 am

Ignore my last post - I figured out the problem.

I wasn't initializing mIv (the ImageView) properly! Such a stupid error, and I spent countless hours on this thinking it was something to do with the Intent call.


Jon
xil3
Freshman
Freshman
 
Posts: 5
Joined: Sun Apr 11, 2010 8:13 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 7 guests