Questions about the android:getslotfrombufferlocked

Source: Internet
Author: User

This problem occurs today when I write a demo that posts photos to the screen after calling the camera. The code is as follows

 Packageandroid.com.java.choosepictest;Importandroid.app.Activity;Importandroid.content.Intent;ImportAndroid.graphics.Bitmap;Importandroid.graphics.BitmapFactory;ImportAndroid.net.Uri;ImportAndroid.os.Bundle;Importandroid.os.Environment;ImportAndroid.provider.MediaStore;ImportAndroid.util.Log;ImportAndroid.view.View;ImportAndroid.widget.Button;ImportAndroid.widget.ImageView;ImportJava.io.File;Importjava.io.FileNotFoundException;Importjava.io.IOException; Public classMainactivityextendsActivity { Public Static Final intTake_photo = 1;  Public Static Final intCrop_photo = 2; PrivateButton Takephoto; PrivateImageView picture; PrivateUri Imageuri; @Override Public voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main); Takephoto=(Button) Findviewbyid (R.id.take_photo); picture=(ImageView) Findviewbyid (r.id.picture); Takephoto.setonclicklistener (NewView.onclicklistener () {@Override Public voidOnClick (View v) {File outputimage=NewFile (Environment.getexternalstoragedirectory (), "Output_image.jpg"); Try{                    if(Outputimage.exists ()) {outputimage.delete ();                } outputimage.createnewfile (); }Catch(IOException e) {e.printstacktrace (); } Imageuri=Uri.fromfile (outputimage); ANDROID.UTIL.LOG.E ("YPC", "uri =" +Imageuri); Try{Bitmap Mbitmap=Bitmapfactory.decodestream ((Getcontentresolver (). Openinputstream (Imageuri))); LOG.E ("YPC", "bitmap =" +Mbitmap); LOG.E ("YPC", "Getcontentresolver (). Openinputstream (Imageuri) =" +getcontentresolver (). Openinputstream (Imageuri));                Picture.setimagebitmap (MBITMAP); }Catch(FileNotFoundException e) {e.printstacktrace (); } Intent Intent=NewIntent ("Android.media.action.IMAGE_CAPTURE");                Intent.putextra (Mediastore.extra_output,imageuri);            Startactivityforresult (Intent,take_photo);    }        }); } @Overrideprotected voidOnactivityresult (intRequestcode,intResultCode, Intent data) {        Switch(requestcode) { CaseTake_photo:if(Requestcode = =RESULT_OK) {Intent Intent=NewIntent ("Com.android.camera.action.CROP"); Intent.setdataandtype (Imageuri,"Image/*"); Intent.putextra ("Scale",true);                    Intent.putextra (Mediastore.extra_output,imageuri); Try{Bitmap Mbitmap=Bitmapfactory.decodestream ((Getcontentresolver (). Openinputstream (Imageuri))); LOG.E ("YPC", "bitmap =" +Mbitmap); LOG.E ("YPC", "Getcontentresolver (). Openinputstream (Imageuri) =" +getcontentresolver (). Openinputstream (Imageuri));                    Picture.setimagebitmap (MBITMAP); }Catch(FileNotFoundException e) {e.printstacktrace ();                } startactivityforresult (Intent,crop_photo); }                 Break;  CaseCrop_photo:if(ResultCode = =RESULT_OK) {                    Try{Bitmap Bitmap=Bitmapfactory.decodestream ((Getcontentresolver (). Openinputstream (Imageuri)));                        Picture.setimagebitmap (bitmap); ANDROID.UTIL.LOG.E ("YPC", "bitmap =" +bitmap); }Catch(FileNotFoundException e) {e.printstacktrace (); }                }                 Break; default: Break; }    }}

I don't know why I have an error. Make a flag and see if you can write a question tomorrow.

Questions about the android:getslotfrombufferlocked

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.