2

After i changing activity in my nav header, i have strange flickers and i want to get rid of them:

enter image description here

Im not sure which part of code should i show, but guess that problem could be in how intents are creating or something like that. Here is a code of my navigation buttons:

@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.main) {
        Intent main = new Intent(main.this, main.class);
        main.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(main);
    } else if (id == R.id.find_friends) {
        Intent findfriends = new Intent(main.this, FindFriends.class);
        findfriends.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(findfriends);
    } else if (id == R.id.followers) {
        Intent followers = new Intent(main.this, Followers.class);
        followers.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(followers);
    } else if (id == R.id.follow) {
        Intent follow = new Intent(main.this, Follow.class);
        follow.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(follow);
    } else if (id == R.id.statistics) {
        Intent statistic = new Intent(main.this, statistic.class);
        statistic.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(statistic);
    } else if (id == R.id.LogOut) {
        FirebaseAuth.getInstance().signOut();
        Intent mainact = new Intent(main.this, MainActivity.class);
        mainact.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(mainact);
    } else if (id == R.id.About) {
        Intent about = new Intent(main.this, About.class);
        about.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(about);
    }

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
Andrej Vilenskij
  • 487
  • 1
  • 7
  • 23
  • Try removing about.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); If that doesn't work, it probably has to do with drawer.closeDrawer(GravityCompat.START); – Joe Nov 20 '19 at 21:21
  • @Joe if i remove drawer.closeDrawer(GravityCompat.START); - animation of drawer just dissapears but problem stays. FLAG_ACTIVITY_REORDER_TO_FRONT i using for not recreating activities that already was created – Andrej Vilenskij Nov 20 '19 at 21:55
  • Why not finish() activities when you leave them, so they get recreated? It will remove the need for FLAG_ACTIVITY_REORDER_TO_FRONT and will decrease the resources used by your app if a user switches through a bunch of activities – Joe Nov 21 '19 at 14:25
  • https://stackoverflow.com/questions/4633543/overridependingtransition-does-not-work-when-flag-activity-reorder-to-front-is-u Thanks to Daniele Segato. You should try overridePendingTransition – whulwj Dec 11 '19 at 13:37

0 Answers0