title: App force close thenewboston android tutorial
body: <p>I have been going through the android tutorial by thenewboston and got stuck up on 41st tutorial. My app is force closing as soon as I open camera activity.</p>
  
  <p>Camera.java</p>
  
  <pre><code>package com.thenewboston.akshit;
  
  import java.io.IOException;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.graphics.Bitmap;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.ImageButton;
  import android.widget.ImageView;
  
  public class Camera extends Activity implements View.OnClickListener {
  
  ImageButton ib;
  Button b;
  ImageView iv;
  Intent i;
  final static int cameraData=0;
  Bitmap bmp;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.photo);
      initialize();
  
  }
  private void initialize() {
      iv = (ImageView) findViewById(R.id.ivReturnedPic);
      b = (Button) findViewById(R.id.bSetWall);
      iv = (ImageView) findViewById(R.id.ivReturnedPic);
      b.setOnClickListener(this);
      ib.setOnClickListener(this);
  }
  
  @Override
  public void onClick(View v) {
      // TODO Auto-generated method stub
      switch (v.getId()){
      case R.id.bSetWall:
          try{
          getApplicationContext().setWallpaper(bmp);}
          catch (IOException e) { e.printStackTrace(); }      
          break;
  
      case R.id.ibTakePic:
          i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
      startActivityForResult(i,cameraData);
  
          break;
  
      }
  
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      // TODO Auto-generated method stub
      super.onActivityResult(requestCode, resultCode, data);
      if(resultCode==RESULT_OK){
          Bundle extras =data.getExtras();
          bmp = (Bitmap) extras.get("data");
          iv.setImageBitmap(bmp); 
  
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Menu.java</p>
  
  <pre><code>package com.thenewboston.akshit;
  
  import android.app.ListActivity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  
  public class Menu extends ListActivity {
  String classes[] = {"StartingPoint", "TextPlay", "Email", "Camera"};
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setListAdapter(new ArrayAdapter&lt;String&gt;(Menu.this, android.R.layout.simple_list_item_1, classes));
  
  }
  
  
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
      // TODO Auto-generated method stub
      String cheese = classes[position];
      super.onListItemClick(l, v, position, id);  
      try{
      Class ourClass = Class.forName("com.thenewboston.akshit." + cheese);
      Intent ourIntent = new Intent(Menu.this, ourClass);
      startActivity(ourIntent);
      }catch(ClassNotFoundException e){
          e.printStackTrace();
      }
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>AndroidManifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.thenewboston.akshit"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="8"
      android:targetSdkVersion="18" /&gt;
  &lt;uses-permission android:name="android.permission.SET_WALLPAPER"/&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
      &lt;activity
          android:name="com.thenewboston.akshit.Splash"
          android:label="Splash" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name="com.thenewboston.akshit.StartingPoint"
          android:label="Starting Point" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="com.thenewboston.akshit.STARTINGPOINT" /&gt;
  
              &lt;category android:name="android.intent.category.DEFAULT" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name="com.thenewboston.akshit.Menu"
          android:label="Starting Point" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="com.thenewboston.akshit.MENU" /&gt;
  
              &lt;category android:name="android.intent.category.DEFAULT" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name="com.thenewboston.akshit.TextPlay"
          android:label="Starting Point" &gt;
      &lt;/activity&gt;
       &lt;activity
          android:name="com.thenewboston.akshit.Email"
          android:label="Starting Point" &gt;
      &lt;/activity&gt;
       &lt;activity
          android:name="com.thenewboston.akshit.Camera"
          android:label="Starting Point" &gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>log</p>
  
  <pre><code>06-28 03:23:03.080: D/dalvikvm(871): Not late-enabling CheckJNI (already on)
  06-28 03:23:06.280: D/gralloc_goldfish(871): Emulator without GPU emulation detected.
  06-28 03:23:09.520: D/dalvikvm(871): GC_FOR_ALLOC freed 55K, 5% free 3032K/3172K, paused 124ms, total 130ms
  06-28 03:23:09.520: I/dalvikvm-heap(871): Grow heap (frag case) to 3.646MB for 635812-byte allocation
  06-28 03:23:09.590: D/dalvikvm(871): GC_FOR_ALLOC freed 6K, 4% free 3646K/3796K, paused 63ms, total 63ms
  06-28 03:23:10.210: I/Choreographer(871): Skipped 72 frames!  The application may be doing too much work on its main thread.
  06-28 03:23:15.810: D/AndroidRuntime(871): Shutting down VM
  06-28 03:23:15.810: W/dalvikvm(871): threadid=1: thread exiting with uncaught exception (group=0xb3a36b90)
  06-28 03:23:15.850: E/AndroidRuntime(871): FATAL EXCEPTION: main
  06-28 03:23:15.850: E/AndroidRuntime(871): Process: com.thenewboston.akshit, PID: 871
  06-28 03:23:15.850: E/AndroidRuntime(871): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thenewboston.akshit/com.thenewboston.akshit.Camera}: java.lang.NullPointerException
  06-28 03:23:15.850: E/AndroidRuntime(871):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at android.app.ActivityThread.access$700(ActivityThread.java:135)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at android.os.Handler.dispatchMessage(Handler.java:102)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at android.os.Looper.loop(Looper.java:137)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at android.app.ActivityThread.main(ActivityThread.java:4998)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at java.lang.reflect.Method.invokeNative(Native Method)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at java.lang.reflect.Method.invoke(Method.java:515)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at dalvik.system.NativeStart.main(Native Method)
  06-28 03:23:15.850: E/AndroidRuntime(871): Caused by: java.lang.NullPointerException
  06-28 03:23:15.850: E/AndroidRuntime(871):  at com.thenewboston.akshit.Camera.initialize(Camera.java:37)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at com.thenewboston.akshit.Camera.onCreate(Camera.java:29)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at android.app.Activity.performCreate(Activity.java:5243)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
  06-28 03:23:15.850: E/AndroidRuntime(871):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
  06-28 03:23:15.850: E/AndroidRuntime(871):  ... 11 more
  06-28 03:23:19.850: I/Process(871): Sending signal. PID: 871 SIG: 9
  </code></pre>