gpt4 book ai didi

java - Android ActivityGroup Activity Intent 导航

转载 作者:行者123 更新时间:2023-12-01 15:32:28 25 4
gpt4 key购买 nike

我在 Activity 组方面面临非常复杂的问题。在我的应用程序中,我使用了 ActivityGroup。对于我使用的其他 Activity 导航:

Intent activityIntent = new Intent(v.getContext(), Reschedule.class);
activityIntent.putExtra("dialog_selcted_Appointment_date_time", selected_date +" "+ selected_time);
replaceContentView("activity3", activityIntent);

private void replaceContentView(String id, Intent newIntent) {
View view = this.getLocalActivityManager().startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) .getDecorView(); this.setContentView(view);}

我的问题是,一旦我在另一个屏幕上导航,现在如果我再进行相同的导航而不更改 Activity ,那么它会给出错误:

02-23 18:16:15.200: E/ACRA(2433): 
Caused by: android.view.WindowManager$BadTokenException: Unable to add window --
token android.app.LocalActivityManager$LocalActivityRecord@44f04458 is not valid; is your activity running?

最佳答案

尝试

View view = getApplicationContext().startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) .getDecorView(); this.setContentView(view);}

此外,ActivityGroup 类现已弃用。为此目的使用 Fragment 会更好、更容易。请参阅http://developer.android.com/guide/topics/fundamentals/fragments.html .

关于java - Android ActivityGroup Activity Intent 导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9414100/

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