android how to save captured image into phones gallery

前端 未结 3 1573
忘掉有多难
忘掉有多难 2020-12-06 07:56

I have two activities. In one activity, I have an ImageView and an camera button. When I press camera button it goes to other activity where two buttons are the

3条回答
  •  不思量自难忘°
    2020-12-06 08:35

    try this..

    String path = Environment.getExternalStorageDirectory() + "/CameraImages/example.jpg";
                                File file = new File(path);
                                Uri outputFileUri = Uri.fromFile( file );
                                Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
                                intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
    
                                startActivityForResult( intent, CAPTURE_IMAGE );
    

    your image will be save at this location "sdcard/CameraImages/example.jpg"

提交回复
热议问题