0

This is my first android application :)

I am following this example: How can I capture a video recording on Android?

My code compiles with no problem. Now, at this code line 47:

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

I get a NullPointerException. So probably cameraView is not found. Here's the declaration.

<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>

I can't understand why. I am plugging in this code into an existing app. This app has its own main Activity, and with a button I start the other Activity from the link above with the exact same code (only the view id changes).

public void showVideo(View w) {

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

The main app has its layout in layout/main.xml, my new Activity (called VideoCapture) is in layout/activity_video_capture.xml

Community
  • 1
  • 1
transient_loop
  • 5,984
  • 15
  • 58
  • 117
  • 3
    Since your layout lacks ``layout_height`` I have to ask; are you calling ``setContentView`` with correct layout id before asking for ``SurfaceView``? – harism Sep 09 '12 at 18:43
  • 1
    harism, I love you!!! That was my mistake, just the line before, I was doing setContentView(R.layout.main); instead of setContentView(R.layout.activity_video_capture); The latter has the actual SurfaceView defined :) – transient_loop Sep 09 '12 at 18:50

0 Answers0