protected void selectPicFromCamera() {
        if (!EaseCommonUtils.isSdcardExist()) {
            Toast.makeText(getActivity(), R.string.sd_card_does_not_exist, Toast.LENGTH_SHORT).show();
            return;
        }       cameraFile = new File(Environment.getExternalStorageDirectory() + "/"  + System.currentTimeMillis() + ".jpg");//        cameraFile = new File(PathUtil.getInstance().getImagePath(), EMClient.getInstance().getCurrentUser()
//                + System.currentTimeMillis() + ".jpg");
        //noinspection ResultOMethodCallIgnored
        Log.v("相机bug","+"+cameraFile);
        cameraFile.getParentFile().mkdirs();
        startActivityForResult(
                new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(cameraFile)),
                REQUEST_CODE_CAMERA);
    }

解决方案 »

  1.   

    你的测试环境是7.0的吗?如果是的话那就去看看这个吧http://blog.csdn.net/lixuce1234/article/details/69577309   应该可以帮到你  如果其他原因的话   那需要你在贴出一下错误日志了
      

  2.   

    我也遇到了同样的问题   
    Process: com.ishucool.yashiretail, PID: 27030java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.io.File.mkdirs()' on a null object reference at com.hyphenate.easeui.ui.EaseChatFragment.selectPicFromCamera(EaseChatFragment.java:873)
    at com.hyphenate.easeui.ui.EaseChatFragment$MyItemClickListener.onClick(EaseChatFragment.java:647)
     at com.hyphenate.easeui.widget.EaseChatExtendMenu$ItemAdapter$1.onClick(EaseChatExtendMenu.java:125)
     at android.view.View.performClick(View.java:5207)
    at android.view.View$PerformClick.run(View.java:21177)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5441)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)就是一个控指针异常cameraFile.getParentFile().mkdirs();出现在这一句上面
      

  3.   

            if (PathUtil.getInstance().getImagePath() == null) {
                PathUtil.getInstance().initDirs("", "", getActivity());
            }
            cameraFile = new File(PathUtil.getInstance().getImagePath(), EMClient.getInstance().getCurrentUser()
                    + System.currentTimeMillis() + ".jpg");
            //noinspection ResultOfMethodCallIgnored
            cameraFile.getParentFile().mkdir();网上说是初始化问题,但实在是发现不了哪里初始化不对了,最后通过该方法解决
    自己判断路径是否为null,是的话则调用PathUtil的initDirs方法
           if (PathUtil.getInstance().getImagePath() == null) {
                PathUtil.getInstance().initDirs("", "", getActivity());
            }