我已经通过调用启动 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/