我的问题与有关如何打开 YouTube 链接的其他问题不同。我的问题是如何打开 YouTube 链接,然后当它在应用程序中打开时,它应该关闭 YouTube 应用程序并再次调用我的MainActivity
这将打开 YouTube 应用。但是,它应该从头开始打开 YouTube 应用程序,而不仅仅是显示之前在后台运行的 YouTube 活动。
MainActivity --> SecondActivity --> Youtube --> ThirdActivity --> Youtube
但我希望 YouTube 应用程序能够从头开始重新加载。但目前,我得到了之前在后台打开的 YouTube 应用程序。
主要活动
Intent intent = new Intent(MainActivity.this,ThirdActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
第二次活动
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();
第三次活动
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();
我想每次从头开始加载它,但它向我显示它暂停的状态。如果您不明白我的问题,请随时发表评论,我会尽力详细说明。提前致谢。