开发者

Android restart activity (with AsyncTask) on completion of another activity

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 i开发者_运维技巧t 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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜