title: Unable to start activity ClassCastException: activity1 cannot be cast to activity2
body: <p>Hello I have 3 activities, Main activity, contains menu, where I can start another activity.
  But I can start only first activity. When I want start second activity, my application shutdown. With following logcat.
  I hope that will be enough, because the activity of 10 meters is a bit long.</p>
  
  <p>Logcat:</p>
  
  <pre><code>09-08 18:50:41.185: D/AndroidRuntime(3065): Shutting down VM
  09-08 18:50:41.195: W/dalvikvm(3065): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
  09-08 18:50:41.285: E/AndroidRuntime(3065): FATAL EXCEPTION: main
  09-08 18:50:41.285: E/AndroidRuntime(3065): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.vkedco.mobappdev.draw_touch_drive_00001/org.vkedco.mobappdev.draw_touch_drive_00001.e_10m}: java.lang.ClassCastException: org.vkedco.mobappdev.draw_touch_drive_00001.y_50m cannot be cast to org.vkedco.mobappdev.draw_touch_drive_00001.y_10m
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at android.os.Handler.dispatchMessage(Handler.java:99)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at android.os.Looper.loop(Looper.java:137)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at android.app.ActivityThread.main(ActivityThread.java:5041)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at java.lang.reflect.Method.invokeNative(Native Method)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at java.lang.reflect.Method.invoke(Method.java:511)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at dalvik.system.NativeStart.main(Native Method)
  09-08 18:50:41.285: E/AndroidRuntime(3065): Caused by: java.lang.ClassCastException: org.vkedco.mobappdev.draw_touch_drive_00001.y_50m cannot be cast to org.vkedco.mobappdev.draw_touch_drive_00001.y_10m
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at org.vkedco.mobappdev.draw_touch_drive_00001.e_10m.onCreate(e_10m.java:107)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at android.app.Activity.performCreate(Activity.java:5104)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
  09-08 18:50:41.285: E/AndroidRuntime(3065):     ... 11 more
  09-08 18:50:44.225: I/Process(3065): Sending signal. PID: 3065 SIG: 9
  </code></pre>
  
  <p>manifest: </p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="org.vkedco.mobappdev.draw_touch_drive_00001"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  
  &lt;uses-sdk
      android:minSdkVersion="8"
      android:targetSdkVersion="15" /&gt;
  
  &lt;application
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
      &lt;activity
          android:name="org.vkedco.mobappdev.draw_touch_drive_00001.MainActivity"
          android:label="@string/title_activity_draw_touch_drive_main"
          android:screenOrientation="portrait" &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="org.vkedco.mobappdev.draw_touch_drive_00001.e_50m"
          android:label="@string/title_activity_main"
          android:screenOrientation="portrait" &gt;
      &lt;/activity&gt;
      &lt;activity
          android:name="org.vkedco.mobappdev.draw_touch_drive_00001.e_10m"
          android:label="@string/title_activity_rifle_10m" &gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  
  &lt;/manifest&gt; 
  </code></pre>
  
  <p>MainActivity:</p>
  
  <pre><code>public class MainActivity extends Activity {    
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          Button btnSimple = (Button) findViewById(R.id.e_50m);
          btnSimple.setOnClickListener(new OnClickListener() {
             public void onClick(View v) {
                 Intent intent = new Intent(MainActivity.this, e_50m.class);
                 startActivity(intent);             
             }
          });
  
          Button btnSimple2 = (Button) findViewById(R.id.e_10m);
          btnSimple2.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
                  Intent intent = new Intent(MainActivity.this, e_10m.class);
                  startActivity(intent);
              }
          });
      }
  }
  
  
  public class e_10m extends Activity{
  
  
  public RelativeLayout mContent;
  y_10m mTicTacToeView = null;
  public static String tempDir;
  public File mypath;
   public static Bitmap mBitmap;
  public static int width;
  public static int height;
  public static int r = 0;
  public static float x;
  public static float y;
  
  public static float X;
  public static float Y;
  
  
  public static double vzdalenost;
  
  
  
   public String current = null;
   private String uniqueId;
   publicy_10m mSignature;
   public View mView;
   static TextView i;
   public static int q=0;
  
  
  
  
  
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.zaznam_ran);      
  
  
  
  
  
  
  
     File directory = new File(Environment.getExternalStorageDirectory() + "/e_10m");
     if(!directory.exists())
  
         directory.mkdir();
  
     uniqueId =  "_" ;
     current = uniqueId + ".png";
  
  
     mypath= new File(directory,current);
  
     mContent = (RelativeLayout) findViewById(R.id.rl);
  
     mSignature = new y_10m(this, null);
     mSignature.setBackgroundColor(Color.TRANSPARENT);
     mContent.addView(mSignature, LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
  
     mView = mContent;
  
  
  
  
  
  
  
      Display display = getWindowManager().getDefaultDisplay();
       width = (display.getWidth());
       height = (display.getHeight());        
      mTicTacToeView = (y_10m) this.findViewById(R.id.pntr);
  
  
  
  
  
  
  
  Button btn3 = (Button) findViewById(R.id.button3);
  
  btn3.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
  
  
          if(y_10m.t == 10){
              y_10m.Vycistit();
  
          }
          y_10m.PridatRanu();
  
      }
  });
  
  
  
  
  
  Button btn4 = (Button) findViewById(R.id.button4);
  
  btn4.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
          y_10m.krouzkyMazat();
  
  
          if (q&gt;=1){q = q-1;}
  
  
      }
  });
  
  
   Button btn5 = (Button) findViewById(R.id.button5);
  
      btn5.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Krouzky_10m.Vycistit();
  
              q=0;
              y_10m.t = 0;
  
          }
      });
  
  
  
  
       Button btn6 = (Button) findViewById(R.id.button6);
  
          btn6.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                      Log.v("log_tag", "Panel Saved");
  
                          mView.setDrawingCacheEnabled(true);
  
  
                  }
  
          });
  
  
  
  }
  
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      MenuInflater inflater = getMenuInflater();
  
      getMenuInflater().inflate(R.menu.activity_draw_touch_drive_main, menu);
      return true;
  }
  
  @Override
  protected void onDestroy() {
  
      super.onDestroy();      
      if ( mTicTacToeView != null ) {
          mTicTacToeView.NemuzemeVykreslovat();
          mTicTacToeView = null;
  
      }
  }
  
  @Override
  public void onLowMemory() {
      super.onLowMemory();
      if ( mTicTacToeView != null ) {
          mTicTacToeView.NemuzemeVykreslovat();
          mTicTacToeView = null;
      }
  }
  
  
  @Override
  protected void onPause() {
      super.onPause();
      if ( mTicTacToeView != null ) {
          mTicTacToeView.NemuzemeVykreslovat();
      }
  }
  
  
  
  @Override
  protected void onStart() {
      super.onStart();
      if ( mTicTacToeView != null ) {
          mTicTacToeView.MuzemeVykreslovat();
      }
      else {
          mTicTacToeView = (y_10m) this.findViewById(R.id.pntr);
          mTicTacToeView.MuzemeVykreslovat();
      }
  
      y_10m.Vycistit();
  
          q=0;
          y_10m.t = 0;
  
  
  }
  
  @Override
  protected void onStop() {
      super.onStop();
      if ( mTicTacToeView != null ) {
          mTicTacToeView.NemuzemeVykreslovat();
      }
  
  }
  
  
   } 
  </code></pre>
  
  <p>pntr view in zaznam_ran:</p>
  
  <pre><code>&lt;org.vkedco.mobappdev.draw_touch_drive_00001.y_50m
      android:id="@+id/pntr"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:tag="Painter" /&gt;
  </code></pre>