我正在使用底部导航菜单,每次itemMenu
我调用一个函数来打开正确的活动:
//In the activty "A" where there's the bottom nav bar:
HelpActivity help = new HelpActivity();
case R.id.navigation_home:
help.openHomeActivity();
在里面HelpActivity
public void openHomeActivity(){
Intent i = new Intent(getApplicationContext(), HomeActivity.class);
startActivity(i);
}
应用程序崩溃了,请问如何解决?
错误
java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法 'android.content.Context android.content.Context.getApplicationContext()'