Android 拍照功能代码

2015-01-11 0 984
Android 拍照功能代码
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()));

    }
}

遇见资源网 java Android 拍照功能代码 http://www.ox520.com/8310.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务