Paul Blundell
Paul Blundell

Reputation: 1857

Android activity finish update previous activity

I have an activity where you can click on a product and it adds it to a basket, a button is then pressed to checkout where a new activity is started, this activity lists everything in the basket with an option to remove the item. If ALL items are removed I am calling finish() on this activity to go back to the previous activity that listed all the products.

The problem is that this previous activity still says X items have been selected, how can I get this to update or to reload?

Upvotes: 3

Views: 6145

Answers (2)

vishalb
vishalb

Reputation: 63

Look at startActivityForResult and onActivityResult functions if you want to return information from child activity back to a parent activity.

onResume is called every time the task/app becomes active (for ex: screen off/on, switching to your app using task switcher etc) and you may not want to refresh the page in all these cases.

Upvotes: 1

Tiago Pasqualini
Tiago Pasqualini

Reputation: 821

You should put your refresh code inside the onResume method of your Activity.

Take a look at the Activity Lifecycle here for more information: http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle

Upvotes: 6

Related Questions