android camera and gallery not working in nexus 5

[亡魂溺海] 提交于 2019-12-05 06:09:29

问题


In my application I use camera and gallery to upload the selected image to server. it's working fine till 4.4.2, but in 4.4.4 nexus5 both camera and gallery don't work. my camera part is in a Fragment.If I try to take a photo using the camera or pick a photo using the gallery I get "please retry" message as per my code.

camera action code:

        String path = Environment.getExternalStorageDirectory()
                + "/appname";
        File photopath = new File(path);
        if (!photopath.exists()) {
            photopath.mkdir();
        }

        try {
            Intent captureIntent = new Intent(
                    MediaStore.ACTION_IMAGE_CAPTURE);

            startActivityForResult(captureIntent, CAMERA_CAPTURE);
        } catch (ActivityNotFoundException anfe) {
            String errorMessage = "Whoops - your device doesn't support capturing images!";
            Toast toast = Toast.makeText(getActivity(), errorMessage,Toast.LENGTH_SHORT);
            toast.show();
        }

......

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    try {
        Log.e("request code", "" + requestCode);
        Log.e("result code", "" + resultCode);
        Log.e("Activity.RESULT_OK", "" + getActivity().RESULT_OK);
    }
    catch(Exception e) {
        Toast.makeText(getActivity(), "Please retry", Toast.LENGTH_SHORT).show();
    }
}

what is the problem behind the 4.4.4 version? or is it my mistake? How can I solve the problem?

来源:https://stackoverflow.com/questions/24492590/android-camera-and-gallery-not-working-in-nexus-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!