I am creating an abstract base class to keep my navigation drawer code in one place and want to implement an onClickListener
on my app title (defined in the toolbar) to start my launch activity
I am using the following code :
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.toolbar_title:
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
return;
}
}
The app works properly, but I read somewhere that one must not use the Application context to start new activities. However, android studio doesn't let me use any other context apart from getApplicationContext
and getBaseContext
, maybe because this class is abstract.
Which context should I use then?