Android相机和图库不在nexus 5中工作

时间:2014-06-30 14:33:59

标签: android android-camera android-gallery android-4.4-kitkat android-camera-intent

在我的应用程序中,我使用相机和图库将所选图像上传到服务器。它在4.4.2之前工作正常,但在4.4.4 nexus5中,相机和图库都不起作用。 我的相机部分处于片段。如果我尝试使用相机拍照或使用图库选择照片,我会根据我的代码“请重试”消息。

相机操作码:

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

4.4.4版本背后的问题是什么?还是我的错?我该如何解决这个问题呢?

0 个答案:

没有答案