title: IllegalStateException : Activity has been destroyed
body: <p>I am getting IllegalStateException : Activity has been destroyed at <code>ft.commit()</code></p>
  
  <p>I have posted the relevant code and pointed out the error line.I dont know what cause the error.</p>
  
  <p><strong>Stacktrace:</strong></p>
  
  <pre><code>07-27 02:01:31.776  15571-15571/com.ms.ha E/AndroidRuntime﹕ FATAL EXCEPTION: main
      java.lang.IllegalStateException: Activity has been destroyed
              at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1397)
              at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:636)
              at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:615)
              at com.ms.ha.activity.MainActivity.articleSelected1(MainActivity.java:248)
              at com.ms.ha.activity.GridActivity3.onClick(GridActivity3.java:98)
              at android.view.View.performClick(View.java:4240)
              at android.view.View$PerformClick.run(View.java:17721)
              at android.os.Handler.handleCallback(Handler.java:730)
              at android.os.Handler.dispatchMessage(Handler.java:92)
              at android.os.Looper.loop(Looper.java:137)
              at android.app.ActivityThread.main(ActivityThread.java:5103)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:525)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>I need to move DetailsFragment class onClick the button in GridActivity.Thats why I am using the instance of mainActivity.</p>
  
  <p><strong>GridActivity3.java:</strong></p>
  
  <pre><code>public class GridActivity3 extends FragmentActivity implements OnClickListener {
  
     .......
     .......
       @Override
      public void onClick(View v) {
  
          switch (v.getId()) {
  
           case R.id.btn_home:
  
           MainActivity main= new MainActivity();
  
           main.articleSelected1(6);
  
  
           break;
  
          }
        }
      }
  </code></pre>
  
  <p><strong>MainActivity.java:</strong></p>
  
  <pre><code>public class MainActivity extends ActionBarActivity implements OnTabChangeListener,ArticleSelectedListener1 {
  
  
   @Override
      public void onArticleSelected1(int position)
      {
          articleSelected1(position);
  
      }
  
      public void articleSelected1(int position)
      {
   if(position==6)
          {
              //     action_bar_hometext.setText(content);
              FragmentManager manager = getSupportFragmentManager();
              FragmentTransaction ft = manager.beginTransaction();
              DetailsFragment newFragment = new DetailsFragment();
              ft.replace(R.id.realtabcontent, newFragment);
              ft.addToBackStack(null);
              ft.commit();    ----&gt; 248th line
  
          }
        }
  </code></pre>
  
  <p>I don't know how to solve this error.Anyone can help me with this.Thank you.</p>