title: Get current visible activity to user
body: <p>I want to get the foreground activity running. And I am able to get this information by using activity manager by using following code.</p>
  
  <pre><code>activityManager = (ActivityManager) FWCommon.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  runningTaskInfoList = activityManager.getRunningTasks(1);
  componentName = runningTaskInfoList.get(0).topActivity;
  </code></pre>
  
  <p>Suppose I have two activities A and B and i call this above code from onResume() of both activities A and B.</p>
  
  <p>Following is the problem</p>
  
  <ol>
  <li>When activity A starts above code gives me topActivity = A</li>
  <li>Then I move from activity A to B and above code gives me topActivity = B</li>
  <li>Then i press Back to move back from activity B to A and above code again gives me topActivity = B instead of A.</li>
  </ol>
  
  <p>Thx
  Dalvin</p>