Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的应用程序有两个活动。使用触摸应用程序图标启动应用程序时,主要活动开始。并转到子活动,然后按主页按钮。然后使用任务杀手杀死应用程序。当用户从最近的列表中选择应用程序时,我想重新启动应用程序,但应用程序从子活动开始。
有谁知道如何解决这个问题?
您需要在子活动中覆盖方法 onStop() 并调用 finish() 这样,当按下主页按钮并从第一个活动重新启动时,您的子活动将被终止
您可以在 androidmanifest.xml:android:launchMode="singleInstance" 中编写以下行,或者尝试这样的操作:
startActivity(new Intent(this,Myclass.class)); this.finish(); //调用子活动后,您只需结束主要活动