Android 拍照功能代码

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
 // Hide the window title.
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.main);
    imageView = (ImageView) this.findViewById(R.id.iv1);
    Button button = (Button) this.findViewById(R.id.bt1);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri
                    .fromFile(new File(Environment
                            .getExternalStorageDirectory(), "temp.jpg")));
            intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
            startActivityForResult(intent, 0);
        }
    });

}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 0 && resultCode == Activity.RESULT_OK) {
        this.imageView.setImageDrawable(Drawable.createFromPath(new File(
                Environment.getExternalStorageDirectory(), "temp.jpg")
                .getAbsolutePath()));

    }
}