0

i do have a little problem. I have a lot of different activities and from all these activities i can belong to one activity (I call it ActivityC). So if i return from ActivityC to the former Activity (ActivityB) with the Return Button, i want that former Activity to reactivate.

I guess it works with onResume() but i never tried that method before!

My question is: How do i use the onResume() Method. I mean does somebody have a little code example? The Problem is, that as soon as i return to the old activity (ActivityB), a database should be updated. I describe my problem one more time in another way. I have three different activities A,B and C. If i return from C to B nothing happens (no database is updated), but if i return from B to A and than again from A to B it works (the database is updated because B is somehow "reactivated".

I want to change this that i only need to go back from C to B to reactivate it!

Charles1
  • 57
  • 8

1 Answers1

0

If you want to perform specific activities each time you resume a certain activity, put that piece of code into a specific function, like doSomething() and call it in your onResume() after calling super.onResume(). Example:

public void doSomething() {
  // Whatever task you want to do goes here
}

public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  // setContentView and all can be done here.

  doSomething();
}

protected void onResume() {
  super.onResume();
  doSomething();
}
varevarao
  • 2,186
  • 13
  • 26
  • Thank you!!! Will try this at once!!! Ähm varevarao... i saw that you're from india. Can i maybe ask you something different? I want to go to an android camp in india, maybe next year. I heard of the droidcon which is something like a camp. But do you know maybe something better??? I know, this got nothing to do with my former question : ) – Charles1 Nov 25 '12 at 10:11
  • Something different? Err.. okay. – varevarao Nov 25 '12 at 10:13
  • @user1824383, I'm not aware of any such camps in India (not that there are no such camps, just that I'm blissfully unaware of such things happening around me). Though I'm sure a quick run through Google would help you in your quest. :) P.S. If the answer worked, please help others find it easily by marking it as accepted. – varevarao Nov 25 '12 at 16:59