gpt4 book ai didi

android - 从其他 Activity 重启 Activity

转载 作者:行者123 更新时间:2023-11-30 01:29:52 24 4
gpt4 key购买 nike

我有两个 Activity A 和 B。我想在从 A Activity 转到 B Activity 时重新启动 B Activity ,我该怎么做?

Intent send_show = new Intent(A.this, B.class);
startActivty(send_show);

最佳答案

要“重新启动”,您只需这样做:

Intent send_show = new Intent(B.this, A.class);
finish(); //here restart the B because you are on B class
startActivty(send_show);

否则你可以调用recreate()

编辑

因为你想“重启”定时器,你可以这样做:

public void onDestroy(){
super.onDestroy();
//you should restart timer or just cancel and re active it in onCreate()
}

关于android - 从其他 Activity 重启 Activity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35894095/

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