Android; How can I initialise state in one activity, then have another refresh that?

只愿长相守 提交于 2019-11-29 11:57:39

It depends what behavior you are looking for. As you have currently implemented it, the first Activity will be refreshed any time that it is displayed to the user. For example, if the user pressed the home button from the first activity and later returned to the first activity via a long press on home, then the first activity would refresh it's data.

If that is what you want, then you're doing it right.

If you only want the first activity to refresh when you press the refresh button on the second activity, then you need to use your Intent to do that. One way would be to add a boolean extra to your Intent:

i.putExtra("reloadContent", true);

Then check for this extra in the onStart menthod.

i u can do it by setting flags for your intent try like below,go through other flags

Intent i = new Intent();
                            i.setClass(this, Rss_Feed.class);
//                          i.setClass(Rss_Feed.this, Bru_Maps.class);
                            i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!