title: Acitivity Two starts before Main Activity
body: <p>I can not find any solution for this problem.<br>
  Here it is.</p>
  
  <p>I have two activities: Main Activity and Triangle Activity and I want to see the Main Activity when app starts.</p>
  
  <p>Here is my Main Activity:</p>
  
  <pre><code>public class MainActivity extends Activity {
      // declare properties
      private String[] mNavigationDrawerItemTitles;
      private DrawerLayout mDrawerLayout;
      private ListView mDrawerList;
  
      private ActionBarDrawerToggle mDrawerToggle;
  
      // nav drawer title
      private CharSequence mDrawerTitle;
  
      // used to store app title
      private CharSequence mTitle;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          // for proper titles
          mTitle = mDrawerTitle = getTitle();
  
          // initialize properties
          mNavigationDrawerItemTitles = getResources().
                  getStringArray(R.array.navigation_drawer_items_array);
          mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
          mDrawerList = (ListView) findViewById(R.id.left_drawer);
  
          // list the drawer items
          ObjectDrawerItem[] drawerItem = new ObjectDrawerItem[4];
  
          drawerItem[0] = new ObjectDrawerItem(R.drawable.triangle, "Trougao");
          drawerItem[1] = new ObjectDrawerItem(R.drawable.rec, "Cetvorougao");
          drawerItem[2] = new ObjectDrawerItem(R.drawable.hexagon, "Mnogougao");
          drawerItem[3]=new ObjectDrawerItem(R.drawable.circle, "Krug");
  
          // Pass the folderData to our ListView adapter
          DrawerItemCustomAdapter adapter = new DrawerItemCustomAdapter(this, 
                  R.layout.drawer_layout, drawerItem);
  
          // Set the adapter for the list view
          mDrawerList.setAdapter(adapter);
  
          // set the item click listener
          mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
  
          // for app icon control for nav drawer
          mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
          mDrawerToggle = new ActionBarDrawerToggle(
                  this,                  /* host Activity */
                  mDrawerLayout,         /* DrawerLayout object */
                  R.drawable.ic_drawer,  /* nav drawer icon to replace 'Up' caret */
                  R.string.drawer_open,  /* "open drawer" description */
                  R.string.drawer_close  /* "close drawer" description */
                  ) {
  
              /** Called when a drawer has settled in a completely closed state. */
              public void onDrawerClosed(View view) {
                  super.onDrawerClosed(view);
                  getActionBar().setTitle(mTitle);
              }
  
              /** Called when a drawer has settled in a completely open state. */
              public void onDrawerOpened(View drawerView) {
                  super.onDrawerOpened(drawerView);
                  getActionBar().setTitle(mDrawerTitle);
              }
          };
  
          // Set the drawer toggle as the DrawerListener
          mDrawerLayout.setDrawerListener(mDrawerToggle);
  
          // enable ActionBar app icon to behave as action to toggle nav drawer
          getActionBar().setDisplayHomeAsUpEnabled(true);
          getActionBar().setHomeButtonEnabled(true);
  
          if (savedInstanceState == null) {
              // on first time display view for first nav item
              selectItem(0);
          }
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
  
          // The action bar home/up action should open or close the drawer.
          // ActionBarDrawerToggle will take care of this.
         if (mDrawerToggle.onOptionsItemSelected(item)) {
             return true;
         }
  
         return super.onOptionsItemSelected(item);
      }
  
      // to change up caret
      @Override
      protected void onPostCreate(Bundle savedInstanceState) {
          super.onPostCreate(savedInstanceState);
          // Sync the toggle state after onRestoreInstanceState has occurred.
          mDrawerToggle.syncState();
      }
  
      // navigation drawer click listener
      private class DrawerItemClickListener implements ListView.OnItemClickListener {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              selectItem(position);
          }
      }
  
      private void selectItem(int position) {
  
          // update the main content by replacing fragments
  
         // Fragment fragment = null;
  
          switch (position) {
          case 0:
              Intent intent = new Intent(this,TriangleActivity.class);
  
              startActivity(intent);
  
          break;
          case 1:
              break;
          case 2:
              break;
          case 3:
              break;
          default:
              break;
          }
          /*
          if (fragment != null) {
              FragmentManager fragmentManager = getFragmentManager();
              fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();*/
  
              // update selected item and title, then close the drawer
             /* mDrawerList.setItemChecked(position, true);
              mDrawerList.setSelection(position);
              setTitle(mNavigationDrawerItemTitles[position]);
              mDrawerLayout.closeDrawer(mDrawerList);*/
      }
  
         /* } else {
              // error in creating fragment
              Log.e("MainActivity", "Error in creating fragment");
          }
      }*/
  
      @Override
      public void setTitle(CharSequence title) {
          mTitle = title;
          getActionBar().setTitle(mTitle);
      }
  }
  </code></pre>
  
  <p>Here is Triangle Activity:</p>
  
  <pre><code>public class TriangleActivity extends FragmentActivity implements ActionBar.TabListener {
  
      private ViewPager viewPager;
      private TabsPagerAdapter mAdapter;
      private ActionBar actionBar;
  
      private String []tabs={"Slika","Povrsina","Obim"};
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.acitivity_triangle);
  
          getActionBar().setDisplayHomeAsUpEnabled(true);
  
          viewPager=(ViewPager) findViewById(R.id.pager);
          actionBar=getActionBar();
          mAdapter=new TabsPagerAdapter(getSupportFragmentManager());
  
          viewPager.setAdapter(mAdapter);
          actionBar.setHomeButtonEnabled(true);
          actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
          actionBar.setHomeButtonEnabled(true);
  
          for (String tab_name : tabs) {
              actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this));
          }
          viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
  
              @Override
              public void onPageSelected(int position) {
                  actionBar.setSelectedNavigationItem(position);
              }
  
              @Override
              public void onPageScrolled(int arg0, float arg1, int arg2) {
                  // TODO Auto-generated method stub
              }
  
              @Override
              public void onPageScrollStateChanged(int arg0) {
                  // TODO Auto-generated method stub
              }
          });
      }
  
      private ActionBar getSupprtActionBar() {
          // TODO Auto-generated method stub
          return null;
      }
  
      @Override
      public void onTabReselected(Tab tab, FragmentTransaction ft) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onTabSelected(Tab tab, FragmentTransaction ft) {
          viewPager.setCurrentItem(tab.getPosition());
  
      }
  
      @Override
      public void onTabUnselected(Tab tab, FragmentTransaction ft) {
          // TODO Auto-generated method stub
          }
  
  
      public boolean onOptionsItemSelected(MenuItem item) {
  
          if (item.getItemId()==android.R.id.home) {
              finish();
      }
       return super.onOptionsItemSelected(item);
  }
      }
  </code></pre>
  
  <p>Here is my AndroidManifest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="org.example.androidsdk.demo"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="14"
          android:targetSdkVersion="21" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppBaseTheme" &gt;
          &lt;activity
              android:name="org.example.androidsdk.demo.MainActivity"
              android:label="@string/app_name"
  
              android:configChanges="orientation|screenSize" &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=".TriangleActivity"&gt;
  
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt; 
  </code></pre>