zoukankan      html  css  js  c++  java
  • Alert---点击拍照弹出对话框

        /**
         * 照片对话框
         *AlertDialog
         */
        private void PhotoDialog() {
            AlertDialog.Builder builder = new Builder(mContext);     //  mContext上下文
            builder.setTitle("上传照片至开心网");
            builder.setItems(new String[] { "拍照上传", "上传手机中的照片" },
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            Intent intent = null;
                            switch (which) {   
                            case 0:   //点击是拍照上传  
                                intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                                File dir = new File("/sdcard/KaiXin/Camera/");
                                if (!dir.exists()) {    // 不存在
                                    dir.mkdirs();     
                                }
                                mKXApplication.mUploadPhotoPath = "/sdcard/KaiXin/Camera/"
                                        + UUID.randomUUID().toString();        //保存图片到sd卡的名字
                                File file = new File(mKXApplication.mUploadPhotoPath);
                                if (!file.exists()) {  // 不存在
                                    try {
                                        file.createNewFile();
                                    } catch (IOException e) {
                                    }
                                }
                                intent.putExtra(MediaStore.EXTRA_OUTPUT,
                                        Uri.fromFile(file));
                                mActivity.startActivityForResult( intent,
                                                ActivityForResultUtil.REQUESTCODE_UPLOADPHOTO_CAMERA);
                                break;
    
                            case 1:  //上传手机中的照片
                                mContext.startActivity(new Intent(mContext,
                                        PhoneAlbumActivity.class));
                                break; 
                            }
                        }
                    });
            builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();   // 取消
                }
            });
            builder.create().show();
        }

     

  • 相关阅读:
    HDU 1813 Escape from Tetris
    BZOJ 2276 Temperature
    BZOJ 4499 线性函数
    BZOJ 3131 淘金
    HDU 5738 Eureka
    POJ 2409 Let it Bead
    POJ 1286 Necklace of Beads
    POJ 1696 Space Ant
    Fox And Jumping
    Recover the String
  • 原文地址:https://www.cnblogs.com/java-g/p/4129634.html
Copyright © 2011-2022 走看看