Android 拍照功能代码
2018-07-20 来源:open-open
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())); } }
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
下一篇:php冒泡排序例子
最新资讯
热门推荐