简体   繁体   English

android启动模式

[英]android launch modes

In my android application i am using standard launch mode for all activities.In my application i have a footer bar with home icon to navigate to homescreen from any application activity.the home screen is getting created that many times.If i place the launch mode as single instance the same activity is popped up but even if the data i am expecting is different it is popping up the same data with initial data. 在我的android应用程序中,我正在对所有活动使用标准启动模式。在我的应用程序中,我有一个带有主页图标的页脚栏,可从任何应用程序活动导航到主屏幕。主屏幕被创建了很多次。如果我放置启动模式作为单个实例,将弹出相同的活动,但是即使我期望的数据不同,也会使用初始数据弹出相同的数据。

Please let me know as how can i get new activity created only if there is change of data. 请让我知道,因为只有在数据更改的情况下,我才能如何创建新的活动。

Please forward me your valuable suggestions 请转发给我您的宝贵建议

singleInstance mode means that first time, when activity is created, onCreate() will be called. singleInstance模式意味着第一次创建活动时,将调用onCreate() However on subsequent invocations onNewIntent() is called instead. 但是,在随后的调用中,将调用onNewIntent()

So you should override onNewIntent() and reload the data and update the display there. 因此,您应该重写onNewIntent()并重新加载数据并在那里更新显示。

You can also try this: 您也可以尝试以下操作:

final Intent i = new Intent(this, HomeActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);

This way, the onCreate of your HomeActivity will run again. 这样,您的HomeActivity的onCreate将再次运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM