开发者

How to refresh my all instaces of an activity

开发者 https://www.devze.com 2023-03-22 10:51 出处:网络
I am facing an issue I open Activity A there is some settings --> Go to Activity B ---> Go to Activity A ---> Change some settings in activity A ---> Go to Acivity C

I am facing an issue

I open Activity A there is some settings --> Go to Activity B ---> 
Go to Activity A ---> Change some settings in activity A ---> Go to Acivity C

In this case If I go back from Activity C I am getting latest setting If I go back I am again I am getting Activity B and again if I go back I am getting Activity A. But in this activity A I am getting the old settings.

How to get latest settings in Activity A here also. Is there any way if i make any change in any activity then if any开发者_如何学C instances of that activity is open those will get the latest data.

Thanks


Use SharedPreferences to save any kind of data you may need after going back to an activity. Just load the data in activity's onResume() - this is the best way to not lose useful data. Hope this helps.


startActivity(new Intent(this,activityB);

go to activityB

startActivity(new Intent(this,activityA);//recall activityA

go to activityA

startActivity(new Intent(this,activityC);

to pass data you can use

Bundle b=new Bundle();
b.putInt("hello",3);

myIntent.putExtras(b);
startActivity(myIntent);


use recreate () in activity A before starting other activity

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号