Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is there a "refresh" ability on an activity?

 
James Elsey
Ranch Hand
Posts: 228
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an activity, inside the onCreate() method it pulls some data from another class

That data might change, how can I refresh it? Do I need to call onCreate() somehow, or is there an easier way?
 
Piyush Patel
Ranch Hand
Posts: 127
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,James

James Elsey : how can I refresh it? Do I need to call onCreate()


you can't call onCreate() method that is Andoird life cycle method. that is being managed by Android OS.

To get refreshed data from another class you can put the code inside onStart() method. that is being called after onCreate().

Go through Android Life Cycle

Thanks :-)

 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that an Activity is created, started, resumed,paused, stopped or destroyed automatically by the system depending on events generated by user. There are callbacks with similar names that help you setup your activity and do what you wish to do across activity life cycle.
What you are referring to is refreshing your data set/data store. There is a subtle difference between the two.

You can refresh your data set any time you wish(by calling appropriate method on your data store instance). And if you do it inside correct Activity life cycle method, your users will see updated data every time.

For e.g.: onResume() is called whenever an Activity is brought to the front. So, if you refresh your data set in onResume() the user will see updated view every time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic