gpt4 book ai didi

android - onNewIntent 没有被调用

转载 作者:行者123 更新时间:2023-11-29 15:02:35 25 4
gpt4 key购买 nike

我已经通过调用启动 Activity 开始了一个新的 Activity 。但是在 Activity 启动后,方法 onNewIntent 中的 finish() 没有被调用!!.

WebActivity.java

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
if (intent.getStringExtra("url") != null) {
Intent intent1 = new Intent(getBaseContext(), WebActivity.class);
intent1.putExtra("url",intent.getStringExtra("url"));
startActivity(intent1);
finish();
}
}

最佳答案

仅供引用

调试首先删除不需要的行

super.onNewIntent(intent);
setIntent(intent);

调用 finish() Intent

Intent intent1 = new Intent(getBaseContext(), WebActivity.class);
intent1.putExtra("url",intent.getStringExtra("url"));
finish();
startActivity(intent1)

您也可以尝试使用 FLAG_ACTIVITY_NO_HISTORY .

If set, the new activity is not kept in the history stack. As soon as the user navigates away from it, the activity is finished. This may also be set with the noHistory attribute.

关于android - onNewIntent 没有被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42197583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com