title: My app stopped logcat error
body: <p>I have this error and i don't know why!</p>
  
  <blockquote>
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437): FATAL EXCEPTION: main</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437): Process:
    com.neurondigital.HighwaySpeed, PID: 1437</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):
    java.lang.RuntimeException: Unable to start activity
    ComponentInfo{com.neurondigital.HighwaySpeed/com.neurondigital.HighwaySpeed.HighwaySpeed}:
    java.lang.NullPointerException</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    android.app.ActivityThread.access$800(ActivityThread.java:135)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    android.os.Handler.dispatchMessage(Handler.java:102)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    android.os.Looper.loop(Looper.java:136)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    android.app.ActivityThread.main(ActivityThread.java:5017)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    java.lang.reflect.Method.invokeNative(Native Method)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    java.lang.reflect.Method.invoke(Method.java:515)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    dalvik.system.NativeStart.main(Native Method)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437): Caused by:
    java.lang.NullPointerException</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    com.neurondigital.HighwaySpeed.HighwaySpeed.onCreate(HighwaySpeed.java:40)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    android.app.Activity.performCreate(Activity.java:5231)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   at
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)</p>
    
    <p>04-28 09:26:55.935: E/AndroidRuntime(1437):   ... 11 more</p>
  </blockquote>
  
  <p>This is the code:</p>
  
  <pre><code>import android.app.Activity;
  
  import android.content.Context;
  
  import android.content.pm.ActivityInfo;
  
  import android.os.Bundle;
  
  import android.os.PowerManager;
  
  import android.os.PowerManager.WakeLock;
  
  import android.view.Display;
  
  import android.view.KeyEvent;
  
  import android.view.Window;
  
  import android.view.WindowManager;
  
  import android.widget.RelativeLayout;
  
  import android.widget.RelativeLayout.LayoutParams;
  
  public class HighwaySpeed extends Activity {
  
      Surface view;
      WakeLock WL;
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          //full screen
          requestWindowFeature(Window.FEATURE_NO_TITLE);
          getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
  
          //wake-lock
          PowerManager PM = (PowerManager)getSystemService(Context.POWER_SERVICE);
          WL = PM.newWakeLock(PowerManager.FULL_WAKE_LOCK, "Graphics");
          WL.acquire();
  
          this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  
          Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
          int rotation = display.getRotation();
          if(rotation == 0)
              view.default_lanscape = true;
          if(rotation == 180)
              view.default_lanscape = true;
          if(rotation == 90)
              view.default_lanscape = false;
          if(rotation == 270)
              view.default_lanscape = false;
      }
      @Override
      public boolean onKeyDown(int keyCode, KeyEvent event) {
      super.onKeyDown(keyCode, event);
          if(keyCode == KeyEvent.KEYCODE_BACK){
              view.back();
              return false;
          }
  
          return false;
      }
  
      protected void onPause(){
          super.onPause();
          view.pause();
          WL.release();
      }
  
      protected void onResume(){
          super.onResume();
          view.resume();
          WL.acquire();
      }
  
      @Override
      protected void onDestroy() {
          super.onDestroy();
          WL.release();
      }
  }
  </code></pre>