title: when trying to open an activity from gridview facing error
body: <p>When trying to open an activity its showing error that activity cannot be instantiated.I had a gridview which has to open different activities, when the gridview is in mainactivity, no problem but when the grid view is in another activity, problem araises</p>
  
  <p>package com.guru.finalpro1;</p>
  
  <p>public class Level1 extends Activity implements AdapterView.OnItemClickListener{</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_level1);
      GridView gva= (GridView)findViewById(R.id.gridView1);
  
  
      gva.setAdapter(new ImageAdaptera(getApplicationContext()));
       gva.setOnItemClickListener(this);
  
  }
  
  @Override
  public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) {
         switch(position){
              case 0:
  
                {
  
                      Intent intenta = new Intent (Level1.this, AA.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  
  
                      startActivityForResult(intenta,0);
  
                  }
  
                  break;
  
              case 1:
              {
                  Intent intentb = new Intent (Level1.this, AB.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  startActivityForResult(intentb,0);
              }
                 break;
  
  
        case 2:
      {
          Intent intentc = new Intent (getBaseContext(), AC.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         startActivityForResult(intentc,0);
      }
     break;
  </code></pre>
  
  <p>case 3:
      {
          Intent intentd = new Intent (getBaseContext(), AD.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         startActivityForResult(intentd,0);
      }
     break;</p>
  
  <p>case 4:
          {
              Intent intente = new Intent (getBaseContext(), AE.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivityForResult(intente,0);
          }
        break;</p>
  
  <pre><code>      }}
  </code></pre>
  
  <p>Error:</p>
  
  <p>10-12 04:55:13.543: E/AndroidRuntime(1145): FATAL EXCEPTION: main
  10-12 04:55:13.543: E/AndroidRuntime(1145): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.guru.finalpro1/com.guru.finalpro1.AA}: java.lang.NullPointerException
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at android.os.Handler.dispatchMessage(Handler.java:99)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at android.os.Looper.loop(Looper.java:137)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at android.app.ActivityThread.main(ActivityThread.java:5103)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at java.lang.reflect.Method.invokeNative(Native Method)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at java.lang.reflect.Method.invoke(Method.java:525)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at dalvik.system.NativeStart.main(Native Method)
  10-12 04:55:13.543: E/AndroidRuntime(1145): Caused by: java.lang.NullPointerException
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at android.app.Activity.findViewById(Activity.java:1853)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at com.guru.finalpro1.AA.(AA.java:26)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at java.lang.Class.newInstanceImpl(Native Method)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at java.lang.Class.newInstance(Class.java:1130)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
  10-12 04:55:13.543: E/AndroidRuntime(1145):     ... 11 more</p>