Return to Fragment blank

0

I'm using Navigation Bottom on intent main and I put a custom alert on another screen to return to it, but when I return the screen goes blank, do you know how I can solve this? Thanks in advance.

Here is the code for my main class:

public class MainActivity extends AppCompatActivity {

    private Toolbar mToolbar;

    private BottomNavigationView mBottomNavigationView;
    private TextView mTitle_Toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        hideItemMenu();
        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        mTitle_Toolbar = (TextView) findViewById(R.id.title_toolbar);

        mBottomNavigationView.setOnNavigationItemSelectedListener
                (new BottomNavigationView.OnNavigationItemSelectedListener() {
                    @Override
                    public boolean onNavigationItemSelected( MenuItem item) {
                        Fragment selectedFragment = null;
                        switch (item.getItemId()) {
                            case R.id.action_item1:
                                mTitle_Toolbar.setText(getString(R.string.tab_call));
                                //mToolbar.setLogo(R.mipmap.ic_reorder_white_24dp);
                                selectedFragment = CalledFragment.newInstance();
                                break;
                            case R.id.action_item2:
                                mTitle_Toolbar.setText(getString(R.string.tab_scale));
                                //mToolbar.setLogo(R.mipmap.ic_assignment_turned_in_white_24dp);
                                selectedFragment = ScaleFragment.newInstance();
                                break;
                            case R.id.action_item3:
                                mTitle_Toolbar.setText(getString(R.string.tab_perfil));
                                //mToolbar.setLogo(R.mipmap.ic_account_box_white_24dp);
                                selectedFragment = Profilefragment.newInstance();
                                break;
                        }
//                        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
//                        transaction.replace(R.id.frame_layout, selectedFragment);
//                        transaction.commit();
                        return true;
                    }
                });
            mBottomNavigationView.setSelectedItemId(0);
    }

    private void hideItemMenu() {
        mBottomNavigationView = (BottomNavigationView) findViewById(R.id.navigation);
        Menu navMenu = mBottomNavigationView.getMenu();
        navMenu.findItem(R.id.action_item2).setVisible(false);
    }

    @Override
    protected void onRestart() {
        super.onRestart(); 
    }

    @Override
    protected void onStart() {
        super.onStart();

        //Manually displaying the first fragment - one time only
        mTitle_Toolbar.setText(getString(R.string.tab_call));
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.replace(R.id.frame_layout, CalledFragment.newInstance());
        transaction.commit();
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();

        Log.i("TAG", "voltando para Main");
    }
}

The Event that should return to it:

mDialog.getBtnAprove().setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mDialog.dismiss();
            mContext.startActivity(new Intent(mContext, MainActivity.class));
            mAct.finish();
        }
    });
    
asked by anonymous 08.09.2017 / 21:39

1 answer

0

I found a solution:

I inserted a flag in the intent: intent.setFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP);

vlw galera

    
08.09.2017 / 22:46