0

これは私の最初の Android アプリケーションです :)

私は次の例に従っています: Android でビデオ録画をキャプチャするにはどうすればよいですか?

私のコードは問題なくコンパイルされます。さて、このコード行 47 で:

45 SurfaceView cameraView = (SurfaceView) findViewById(R.id.omVideoView);
46 Log.v(TAG, "after get camera view");
47 holder = cameraView.getHolder();

NullPointerException が発生します。したがって、おそらくcameraViewが見つかりません。これが宣言です。

<LinearLayout 
   android:id="@+id/LinearLayout01"
   android:layout_height="fill_parent" 
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:orientation="vertical">

     <SurfaceView 
        android:id="@+id/omVideoView"
        android:layout_width="fill_parent"        
        android:layout_gravity="center_horizontal"/>


</LinearLayout>

理由がわかりません。このコードを既存のアプリにプラグインしています。このアプリには独自のメイン アクティビティがあり、ボタンを使用して、上記のリンクからまったく同じコードを使用して他のアクティビティを開始します (ビュー ID のみが変更されます)。

public void showVideo(View w) {

    Intent intent = new Intent(skeletonActivity.this, VideoCapture.class);
    startActivityForResult(intent, CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);
}

メイン アプリのレイアウトは layout/main.xml にあり、私の新しいアクティビティ (VideoCapture と呼ばれます) は layout/activity_video_capture.xml にあります。

4

0 に答える 0