title: Get current activity in base activity intent
body: <p>I have a BaseActivity class which I extend in other activities. I have a menu at at the bottom which consists of 5 buttons. Currently I am using setOnClickListener whenever the menu button is clicked and I have duplicated the code in every activity. Obviously this is not a good practise. If I have to make any small change I have to edit in every activity which becomes cumbersome. So I am trying to optimise it by placing different methods in BaseActivity and calling that method in xml onClick.</p>
  
  <p>The following code says that I am currently on MainActivity.this and it will open FindActivity.class. The following works if the code is in MainActivity class</p>
  
  <pre><code>Public Class MainActivity extends BaseActivity{
  
          Intent intent = new Intent(MainActivity.this, FindActivity.class);
          startActivity(intent);
  }
  </code></pre>
  
  <p>But what I am trying to achieve is having the above code in BaseActivity which will be extended by MainActivity obviously.</p>
  
  <pre><code>Public Class BaseActivity extends ActionBarActivity{
  
          Intent intent = new Intent("This should be MainActivity.class", FindActivity.class);
          startActivity(intent);
  }
  </code></pre>
  
  <p>Now the problem here is I am unsure of how to get the MainActivity.this in the Intent parameter in BaseActivity when I am on MainActivity. Basically I am not sure how to get the context there.</p>
  
  <p>Any help will be greatly appreciated.</p>
  
  <p>Please let me know if the above is unclear and requires more explanation.</p>
  
  <p>Thanks in advance.</p>