title: getting nullpointer exception on getLocalActivityManager().getCurrentActivity()
body: <p>I have a tabview which has 5 tab.Each and every is a single activity.In one tab it is opening a new activity which opening a alert.Till now every thing works fine.</p>
  
  <p>My problem is when I am coming back from(Back button press) that child activity it is calling onBackPressed of it's parent activity so I am checking the activity name <code>getLocalActivityManager().getCurrentActivity().toString()</code> it also working when I am pressing back button from child activity, It check the activity name using <code>getLocalActivityManager().getCurrentActivity().toString()</code>.</p>
  
  <p>But when I am pressing back button from my parent activity it's giving NullPointer Exception. May be <code>getLocalActivityManager().getCurrentActivity().toString()</code> not working when calling from parent activity</p>
  
  <p><strong>LogCat Error</strong></p>
  
  <p><img src="https://i.stack.imgur.com/EbkLg.png" alt="enter image description here"></p>
  
  <p><strong>Parent activity</strong></p>
  
  <pre><code>public class ProgressActivity extends ActivityGroup 
  {
  private ArrayList&lt;View&gt; history;
  public void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.progress_tabview);
      this.history = new ArrayList&lt;View&gt;();
  }
  public void showProgress(View v) 
  {
      Intent intMyProg = new Intent(this,ShowProgress.class);
      //intMyProg.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
      //startActivity(intMyProg);
  
      //This will help to open a new activity within existing TabView
      //Need to extend ActivityGroup
      //Need to declare "private ArrayList&lt;View&gt; history;"
      //Need to Define "this.history = new ArrayList&lt;View&gt;();" within onCreate
      View MyView = getLocalActivityManager()
              .startActivity("MyIntent", intMyProg
              .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP))
              .getDecorView();
  
  
      replaceView(MyView);
  }
  
  public void replaceView(View v) 
  {
      history.add(v);
      setContentView(v);
  }
  
  //@Override  
  public void onBackPressed() 
  {  
      String activityName = getLocalActivityManager().getCurrentActivity().toString();
  
      if(activityName.contains("ShowProgress"))
      {
          getCurrentActivity().onBackPressed();
      }
      else
      {
          Toast.makeText(getApplicationContext(), "Back button from parent Activity", Toast.LENGTH_SHORT).show();
          //finish();
      }
  }
  }
  </code></pre>
  
  <p><strong>Child activity</strong></p>
  
  <pre><code>public class ShowProgress extends ActivityGroup
  {
  private ArrayList&lt;View&gt; history;
  public void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.progress);
      this.history = new ArrayList&lt;View&gt;();
  
      AlertDialog alertDialog = new AlertDialog.Builder(ShowProgress.this.getParent()).create();
      alertDialog.setTitle("Hello ...");
      alertDialog.setMessage("Hello world this is Anirban !");
      alertDialog.setIcon(R.drawable.tick);
      alertDialog.setButton("OK", new DialogInterface.OnClickListener() 
      {
          public void onClick(DialogInterface dialog, int which) 
          {
              //Toast.makeText(getApplicationContext(), "You clicked on OK", Toast.LENGTH_SHORT).show();
          }
      });
      alertDialog.show();
  }
  
  //@Override  
  public void onBackPressed() 
  {  
      Intent intMyProg = new Intent(this,ProgressActivity.class);
      View MyView = getLocalActivityManager()
              .startActivity("MyIntent", intMyProg
              .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP))
              .getDecorView();
  
      replaceView(MyView);
  }
  
  public void replaceView(View v) 
  {
      history.add(v);
      setContentView(v);
  }
   }
  </code></pre>