سؤال

I suppose the title is a bit confusing but here is what I'm trying to do:

I have a class called ManageClass which lists the entries of a database. I have written another private class within ManageClass which extends AsyncTask so that I can display a progress dialog while I'm getting the data from the database. Now when I click on an item I create a new Intent which takes me to my ViewItem class. I've added a button there so that the user can delete that particular entry that he/she is looking at. All of the above work fine.

Now I want after deleting that entry to kill the activity and go back to the previous one (the one displaying the list) but I want to refresh the listings.

My problem is that I cant use onResume() cause it will also be called when the activity is resumed after the AsyncTask finishes.

Could anyone help me with that? I'm really stuck... all ideas are welcome!!!

هل كانت مفيدة؟

المحلول

If I understand your app workflow you should use startActivityForResult instead of launching a new Activity via intent.

Look at here fore some example

Basically you can launch a new Activity and wait for a result via callback on the "opener" activity. so you can avoid to put your logic into onResume method

نصائح أخرى

I think this link with give your answer.

Download the project and run it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top