开发者

camera code with interface to select from album or camera

开发者 https://www.devze.com 2023-03-29 03:05 出处:网络
Has开发者_Python百科 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 suggest

Has开发者_Python百科 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


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();
        }


  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

0

精彩评论

暂无评论...
验证码 换一张
取 消