Nexus 7을 사용하는 카메라의 Android 동영상 기록은 null 데이터를 반환합니다.

user2885906

내 앱에는 카메라에서 비디오를 녹화하는 기능이 있습니다. 코드는 모든 장치에서 잘 작동하지만 nexus-7 (android OS 4.3)에서는 null onActivityResult(int requestCode, int resultCode, Intent data)메서드가 발생합니다.

내 코드를 디버깅 할 때 nexus-7 (Android OS 4.3)의 경우 Intent 데이터가 null 인 것으로 나타났습니다.

그것에 대한 몇 가지 해결책을 제안하십시오.

다음은 recordVideo 메소드의 코드입니다.

  private void recordVideo() {
        Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);


        // set video quality
        // 1- for high quality video
        Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);


        // start the video capture Intent
        startActivityForResult(intent, CAMERA_CAPTURE_VIDEO_REQUEST_CODE);
    }
프라 빈 샤르마

다음과 같이 recordView 메소드를 수정하십시오.

private void recordVideo() {
intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);    
   fileUri = getOutputMediaFile(MEDIA_TYPE_VIDEO);  // create a file to save the video in specific folder (this works for video only)
    intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // set the video image quality to high

    // start the Video Capture Intent
    startActivityForResult(intent, REQUEST_VIDEO_CAPTURED_NEXUS);

 }

// 그런 다음 onActivityResult 메서드에서

 protected void onActivityResult(int requestCode, int resultCode, Intent data) {

            if (resultCode == Activity.RESULT_OK) {
                switch (requestCode) {
        case REQUEST_VIDEO_CAPTURED_NEXUS:
        this.videoFromCameraNexus(resultCode, data);
        break;

    default:
                    break;
                }


            }
        }

// videoFromCameraNexus 메서드

private void videoFromCameraNexus(int resultCode, Intent data) {

        if(fileUri != null) {
            Log.d(TAG, "Video saved to:\n" + fileUri);
            Log.d(TAG, "Video path:\n" + fileUri.getPath());
            Log.d(TAG, "Video name:\n" + getName(fileUri)); 
    // use uri.getLastPathSegment() if store in folder
    //use the file Uri.
        }
    }
Get the output Media file uri with the following Method

public Uri getOutputMediaFile(int type)
    {
        // To be safe, you should check that the SDCard is mounted

        if(Environment.getExternalStorageState() != null) {
            // this works for Android 2.2 and above
            File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES), "SMW_VIDEO");

            // This location works best if you want the created images to be shared
            // between applications and persist after your app has been uninstalled.

            // Create the storage directory if it does not exist
            if (! mediaStorageDir.exists()) {
                if (! mediaStorageDir.mkdirs()) {
                    Log.d(TAG, "failed to create directory");
                    return null;
                }
            }

            // Create a media file name
            String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
            File mediaFile;
           if(type == MEDIA_TYPE_VIDEO) {
                mediaFile = new File(mediaStorageDir.getPath() + File.separator +
                "VID_"+ timeStamp + ".mp4");
            } else {
                return null;
            }

            return Uri.fromFile(mediaFile);
        }

        return null;
    }

이것이 당신을 도울 수 있기를 바랍니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

nexus 4에서 작동하지 않는 사진이나 동영상을 촬영하기위한 Android 파일 선택기 또는 카메라

Android startActivityForResult는 카메라를 사용할 때 onActivityResult에 null을 반환합니다.

코 루틴 비동기를 사용하여 Room 데이터베이스가 Null을 반환합니다.

displayName은 이메일과 비밀번호를 사용하여 기록 할 때 null을 반환합니다.

android android.provider.MediaStore.ACTION_VIDEO_CAPTURE는 nexus 7에서 null onActivityResult를 반환합니다.

ACTION_VIDEO_CAPTURE의 동영상이 재생 후 null 동영상을 반환합니다.

getPlaylist는 Youtube IFrame API를 사용할 때 하나의 동영상 만있는 배열을 반환합니다.

테스트 환경의 DataService는 InMemoryDb 데이터를 가져올 때 항상 null을 반환합니다.

라 라벨은 'with'를 사용할 때 null을 반환합니다.

Nexus 5에서 Android 카메라를 사용하여 이미지를 캡처 한 후 Null 포인터

탭 막대를 사용하는 스캐폴드에서 위젯이 사용될 때 텍스트 필드의 값은 항상 null을 반환합니다.

Non-Live Android 앱은 등록된 테스트 기기를 사용하지 않는 한 AdMob 광고 또는 동영상을 표시하지 않습니다.

활동 결과에 카메라 의도는 samsung s4에서 null을 반환합니다.

Android의 기본 카메라 앱을 사용하여 사진을 캡처하면 SecurityException이 발생합니다.

Android 카메라 2는 이전 버전과의 호환성을 지원하는 카메라 장치만 사용해야 합니다.

라우터 getCurrentNavigation은 항상 null을 반환합니다.

내 API는 데이터를 호출할 때 항상 null을 반환합니다.

YouTube 데이터 API는 몇 개의 동영상으로 만 json을 반환합니다.

사용자 지정 Android 대화 상자의 EditText가 null을 반환합니다.

springrepository 메소드 getById는 null을 반환하지만 findById는 데이터를 반환합니다.

SQL 쿼리는 C #을 사용하여 너무 많은 동일한 열 데이터를 반환합니다.

Android Nexus 7은 eclipse의 xhdpi 폴더와 기기의 hdpi 폴더를 사용합니다.

사용자 정의 UserManager는 항상 null을 반환합니다.

FirebaseInstanceId.Instance.Token은 더 이상 사용되지 않으며 Xamarin.Firebase.Messaging을 사용하여 Xamarin.Android에서 null을 반환합니다.

BluetoothManager.OpenGattServer ()가 Nexus 7에서 항상 null을 반환하는 이유는 무엇입니까?

Android Google Maps v2는 사용자가 카메라 이동을 중지하면 asynctask를 실행합니다.

Oracle PL/SQL: 열에 "하나 이상의 null 값" 또는 "데이터를 찾을 수 없음"이 있는 경우 true를 반환합니다.

카메라의 Android getSupportedPreviewSizes ()는 3 가지 크기 만 반환합니다.

Xrm.Page.getControl은 IE 11에서 작동하며 개체를 반환하지만 Edge 브라우저의 동일한 코드는 null을 반환합니다.

TOP 리스트

  1. 1

    Matlab의 반복 Sortino 비율

  2. 2

    ImageJ-히스토그램 빈을 변경할 때 최대, 최소 값이 변경되는 이유는 무엇입니까?

  3. 3

    Excel : 합계가 N보다 크거나 같은 상위 값 찾기

  4. 4

    C #에서 'System.DBNull'형식의 개체를 'System.String'형식으로 캐스팅 할 수 없습니다.

  5. 5

    원-사각형 충돌의 충돌 측면을 찾는 문제

  6. 6

    Oracle VirtualBox-설치를 위해 게스트를 부팅 할 때 호스트 시스템이 충돌 함

  7. 7

    어떻게 아무리 "나쁜", ANY의 SSL 인증서와 HttpClient를 사용하지합니다

  8. 8

    Ubuntu는 GUI에서 암호로 사용자를 만듭니다.

  9. 9

    잘못된 상태 예외를 발생시키는 Apache PoolingHttpClientConnectionManager

  10. 10

    Python 사전을 사용하는 동안 "ValueError : could not convert string to float :"발생

  11. 11

    openCV python을 사용하여 텍스트 문서에서 워터 마크를 제거하는 방법은 무엇입니까?

  12. 12

    Vuetify 다중 선택 구성 요소에서 클릭 한 항목의 값 가져 오기

  13. 13

    C ++ VSCode에서 같은 줄에 중괄호 서식 지정

  14. 14

    Cassandra에서 버전이 지정된 계층의 효율적인 모델링

  15. 15

    JQuery datepicker 기능이 인식되지 않거나 새 프로젝트에서 작동하지 않음

  16. 16

    cuda 11.1에서 Pytorch를 사용할 때 PyTorch가 작동하지 않음: Dataloader

  17. 17

    jfreecharts에서 x 및 y 축 선을 조정하는 방법

  18. 18

    상황에 맞는 메뉴 색상

  19. 19

    마우스 휠 JQuery 이벤트 핸들러에 대한 방향 가져 오기

  20. 20

    매개 변수에서 쿼리 객체를 선언하는 방법은 무엇입니까?

  21. 21

    Maven은 아이 프로젝트 대상 폴더를 청소하지

뜨겁다태그

보관