title: Error when trying to add splash screen - android app
body: <p>I'm an android newbie</p>
  
  <p>I was following this tutorial <a href="http://www.onlymobilepro.com/2013/01/16/android-beginner-creating-splash-screen/" rel="nofollow">Android splash screen howto</a>, it's a little outdated, but anyways.</p>
  
  <p>I just add the new layout file <code>splash.xml</code> into res/layout, and then the image into drawable/mdpi, then I change the main image into MainActivity.java, ie:</p>
  
  <pre><code>setContentView(R.layout.activity_main);
  </code></pre>
  
  <p>to</p>
  
  <pre><code>setContentView(R.layout.splash);
  </code></pre>
  
  <p>Being <code>activity_main</code> the name of the default layout, activity_main.xml, and <code>splash</code> the name of the other layout called splash.xml.</p>
  
  <p>But application stops, says the application has unfortunately stopped, and I can't even access it.</p>
  
  <p>I don't know what am I missing here, here's the interesting code on MainActivity.java:</p>
  
  <pre><code> protected void onCreate(Bundle savedInstanceState) 
    {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
  
  
  
      getWindow().setFormat(PixelFormat.TRANSLUCENT);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      getWindow().setFlags(
                           WindowManager.LayoutParams.FLAG_FULLSCREEN,
                           WindowManager.LayoutParams.FLAG_FULLSCREEN);
  
      setContentView(R.layout.splash);
  
      relativeLayout=(RelativeLayout) findViewById(R.id.containerImg);
      relativeLayout.setDrawingCacheEnabled(true);
      cameraSurfaceView = (SurfaceView)
                                         findViewById(R.id.surfaceView1);
    //  cameraSurfaceView.setLayoutParams(new FrameLayout.LayoutParams(640, 480));
      cameraSurfaceHolder = cameraSurfaceView.getHolder();
      cameraSurfaceHolder.addCallback(this);
  //    cameraSurfaceHolder.setType(SurfaceHolder.
    //                                               SURFACE_TYPE_PUSH_BUFFERS);
  
  
  
  
      btnCapture = (Button)findViewById(R.id.button1);
      btnCapture.setOnClickListener(new OnClickListener() 
      {   
        @Override
        public void onClick(View v) 
        {
           // TODO Auto-generated method stub
           camera.takePicture(cameraShutterCallback, 
                                         cameraPictureCallbackRaw,
                                         cameraPictureCallbackJpeg);
        }
      });
    } 
  </code></pre>
  
  <p>My <code>activity_main.xml</code>:</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".MainActivity" &gt;
  
  &lt;RelativeLayout
      android:id="@+id/containerImg"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
          &lt;SurfaceView
              android:id="@+id/surfaceView1"
              android:layout_width="1276px"
              android:layout_height="745px"
              android:layout_centerInParent="true" /&gt;
  
          &lt;ImageView
              android:id="@+id/imageView1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignBottom="@+id/surfaceView1"
              android:layout_alignLeft="@+id/surfaceView1"
              android:layout_marginLeft="20px"
              android:src="@drawable/mark3" /&gt;
  
  &lt;/RelativeLayout&gt;
  
  &lt;Button
     android:id="@+id/button1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_gravity="right|center_vertical"
     android:background="@drawable/camera" /&gt;
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>My <code>splash.xml</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
  
  &lt;ImageView
      android:src="@drawable/splash"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:scaleType="fitXY"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Maybe I should use the same <code>activity_main.xml</code> for this purposes, not really sure...</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Logcat:</p>
  
  <pre><code>3774-3774/com.kkoci.photo E/AndroidRuntime﹕ FATAL EXCEPTION: main
  java.lang.RuntimeException: Unable to start activity     ComponentInfo{com.kkoci.photo/com.kkoci.photo.MainActivity}:     java.lang.NullPointerException
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2245)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
          at android.app.ActivityThread.access$700(ActivityThread.java:150)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:175)
          at android.app.ActivityThread.main(ActivityThread.java:5279)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:511)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
          at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.NullPointerException
          at com.kkoci.photo.MainActivity.onCreate(MainActivity.java:65)
          at android.app.Activity.performCreate(Activity.java:5283)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
  at android.app.ActivityThread.access$700(ActivityThread.java:150)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:175)
  at android.app.ActivityThread.main(ActivityThread.java:5279)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>