First of all I'm sorry for the mistakes (bugged keyboard).
Well I'm trying to call an Activity through the code below, this code is in my MainActivity.java. I created the fragments to be called through the Drawer Menu and it works perfectly. My goal is to call an Activity directly from this menu but it does not work, the application compiles runs right but when I tap the desired item (on) the app hangs.
I'm using this code to try calling ActivityOn.
Intent iSobre = new Intent(this, ActivitySobre.class);
startActivity(iSobre);
I've searched for and found codes like getActivity (), but that does not work.
MainActivity.java
private void displaySelectedScreen(int id){
android.support.v4.app.Fragment fragment = null;
switch (id){
case R.id.nav_home:
fragment = new FragmentHome();
break;
case R.id.nav_notificacao:
fragment = new FragmentNotificacao();
break;
case R.id.nav_favorito:
fragment = new FragmentFavoritos();
break;
case R.id.nav_minhaconta:
fragment = new FragmentMinhaConta();
break;
case R.id.nav_share:
fragment = new FragmentSobre();
break;
case R.id.item_sobre:
Intent iSobre = new Intent(this, ActivitySobre.class);
startActivity(iSobre);
//fragment = new FragmentSobre();
break;
}
if(fragment != null){
android.support.v4.app.FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.content_main, fragment);
ft.commit();
}
Does anyone have any idea how to fix this? Thank you in advance.