I'm using a bottom navigation menu, on each itemMenu
i'm calling a function to open the correct Activity:
//In the activty "A" where there's the bottom nav bar:
HelpActivity help = new HelpActivity();
case R.id.navigation_home:
help.openHomeActivity();
In the HelpActivity
public void openHomeActivity(){
Intent i = new Intent(getApplicationContext(), HomeActivity.class);
startActivity(i);
}
The app crashes, how to solve this, please?
the error
See Question&Answers more detail:osjava.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference