title: How to open Youtube video link in android app?
body: <p>My question is not similar to other questions about how to open YouTube links. My question is how to open a YouTube link, and then when it opens in the app, it should close the YouTube app and again call my <code>MainActivity</code> which opens the YouTube app. It should however open the YouTube app from scrath and not just show the previous YouTube Activity which is running in the background.</p>
  
  <p>MainAcitivy --> SecondActivity --> Youtube --> ThirdActivity --> Youtube</p>
  
  <p>But I want the YouTube app to load again from scratch. But currently, I am getting the previously opened YouTube app which was in the background.</p>
  
  <p>MainActivity</p>
  
  <pre><code>Intent intent = new Intent(MainActivity.this,ThirdActivity.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
  startActivity(intent);
  finish();
  </code></pre>
  
  <p>SecondActivity</p>
  
  <pre><code>startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link)));
  sleep(10000);
  Intent intent=new Intent(getApplicationContext(),ThirdActivity.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
  startActivity(intent);
  finish();
  </code></pre>
  
  <p>ThirdActivity</p>
  
  <pre><code>sleep(5000);
  Toast.makeText(getApplicationContext(),"third",Toast.LENGTH_SHORT).show();
  Intent intent=new Intent(getApplicationContext(),SecondActivity.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
  startActivity(intent);
  finish();
  </code></pre>
  
  <p>I want to load it each time again from scratch, but it's showing me the state where it was paused. If you don't understand my question, please be free to comment and I will try to elaborate more. Thanks in advance.</p>