Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override OnResume() method of all activities Android

I have and app with more than 10 activities and I would like override the method onResume() with the same code in all of them.

I know that I can override this method in each activity, but I'm looking for an efficient solution.

Moreover I would like inside this onResume show a message depending what activity is coming from, for example: if you are in the MainActivity I want that this common onResume detects that is coming from this activity and show I'm coming from MainActivity

Thank you.

like image 657
user1677266 Avatar asked Sep 27 '12 08:09

user1677266


1 Answers

you should Override activity in a BaseClass and use your BaseClass instead of Activity in the other activities:

public class BaseClass extends Activity 
{

  public void onResume() 
  {
    // common code
  } 
}

public class OtherClass extends BaseClass 
{
}
like image 121
Blackbelt Avatar answered Nov 02 '22 23:11

Blackbelt