Farhan
Farhan

Reputation: 3226

How to refresh activity

I have an android application that pulls a list of videos stored in an sd-card and plays them.

When I click on the play button, a separate activity starts with VideoView, and I need to refresh the main activity that called the VideoView activity to play the video. What I need is that when the video is finished or the user clicks the back button, I want the activity to be refreshed. Any advice would be appreciated.

Upvotes: 3

Views: 29702

Answers (4)

Adam Greenberg
Adam Greenberg

Reputation: 54

I posted this on another link, try this:

finish();startActivity(getIntent());

OR

// Refresh main activity upon close of dialog box
Intent refresh =new Intent(this, ActivityWeAreIn.class);
startActivity(refresh);

Note: this also works with Activity objects or from Fragments using getActivity()

Upvotes: 2

Mahesh
Mahesh

Reputation: 194

Will this work for you?

public void onResume(Bundle s) {
       this.onCreate(s);
}

Upvotes: 0

Ted Hopp
Ted Hopp

Reputation: 234807

Override onResume() and update your activity there. How you update it depends on what kind of activity it is and what needs updating. If you're using an ArrayAdapter in a ListActivity, for instance, you can call getListAdapter().notifyDataSetChanged() after updating the data.

Upvotes: 4

thaussma
thaussma

Reputation: 9886

Implement onResume() see docs

Upvotes: 0

Related Questions