2

Has anyone implelemented a UI where you can choose from album or camera and then the camera opens and you can click and then click on a use button to use that. Please give any suggestions or reference project links

Thanks Max

max
  • 3,047
  • 5
  • 20
  • 17

2 Answers2

1
  1. Here is a former question & answer for the select-dialog: Allow user to select camera or gallery for image

  2. just use this Camera Preview sample from google to get an image.

  3. write that image to sd card then with the code from this sample: DataStorage

  4. and then use an image-view layout to display the former written file: ImageView

Community
  • 1
  • 1
berlindev
  • 1,753
  • 14
  • 22
1

use the below code to call UI to select camera or gallery,

private void openAddPhoto() {

            String[] addPhoto=new String[]{ "Camera" , "Gallery" };
            AlertDialog.Builder dialog=new AlertDialog.Builder(this);
            dialog.setTitle(getResources().getString(R.string.method));

            dialog.setItems(addPhoto,new DialogInterface.OnClickListener(){
                @Override
                public void onClick(DialogInterface dialog, int id) {

                    if(id==0){
                        // Call camera Intent
                    }
                    if(id==1){
                        //call gallery
                    }
                }
            });     

            dialog.setNeutralButton("cancel",new android.content.DialogInterface.OnClickListener(){
                @Override
                public void onClick(DialogInterface dialog, int which) {

                    dialog.dismiss();               
                }});
            dialog.show();
        }
ilango j
  • 5,967
  • 2
  • 28
  • 25