• 调用系统拍照


    // 如果点击的是拍照按钮
    case R.id.btn_map_camera: {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    startActivityForResult(intent, CAMERA_REQUESTCODE);
    }
    break;
    // 调用系统的方法,进入拍照界面

    /**
    * 回调和拍照功能
    */
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    try {
    switch (requestCode) {
    case CAMERA_REQUESTCODE:
    if (resultCode == Activity.RESULT_OK && data != null) {
    Bitmap image = (Bitmap) data.getExtras().get("data");
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    image.compress(CompressFormat.JPEG, 100, bos);
    byte[] imagebytes = bos.toByteArray();// 照片信息

    Bundle bundle = new Bundle();
    bundle.putByteArray(CameraActivity.IMAGE_BUFFER, imagebytes);
    Intent intent = new Intent();
    intent.putExtras(bundle);
    intent.setClass(MapActivity.this, CameraActivity.class);
    startActivity(intent);
    }
    break;
    default:
    break;
    }
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
  • 相关阅读:
    python匹配中文和非中文
    Django mysql连接错误
    linux搭建postfix邮件服务器
    linux编译安装redis
    python将py文件打包成可运行的exe文件
    mysql表结构自动生成golang struct
    linux离线安装nginx+uwsgi
    Sass/Scss
    CSS变量和浏览器前缀
    CSS中常用的函数
  • 原文地址:https://www.cnblogs.com/jh5240/p/2376177.html
Copyright © 2020-2023  润新知