title: Android | Print activity task stack/s in LogCat
body: <p>I want to print all the tasks that my Android app has initiated with the names of the activities within them on LogCat. Is there any API in the SDK that can provide me this information?</p>
  
  <p><strong><em>p.s. I can't and don't want to use the adb shell commands as I want to print the logs in LogCat</strong>.</em></p>
  
  <p><strong>Note:</strong> I've searched quite a bit and all I've found are the adb shell commands which I can't use. Please keep that in mind while answering.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Here's an example of what I want with 2 scenarios:</p>
  
  <ol>
  <li>App starts with activity A, I finish it and start activity B. Then I
  press a button on activity B that starts activity C. Now my default
  task would like <code>C -&gt; B</code> i.e. when I press back, I'll see activity
  B and on pressing back app would finish and the launcher will be
  displayed.</li>
  <li>I open activity A, B &amp; C consecutively then I launch an
  activity X with intent flags <code>Intent.FLAG_ACTIVITY_NEW_TASK |
  Intent.FLAG_ACTIVITY_CLEAR_TASK</code> and then open activities Y &amp; Z. The
  current task will now look like <code>Z -&gt; Y -&gt; X</code>.</li>
  </ol>
  
  <p>So, I want to print these in logcat:</p>
  
  <ol>
  <li><code>C -&gt; B</code> in case 1</li>
  <li><code>Z -&gt; Y -&gt; X</code> in case 2</li>
  </ol>