White screen in transition between activities

Asked

Viewed 96 times

2

I have a project in which I developed a method to save a reference to the activity current and when I used the HOME from the next screen, it returned to the activity using that saved reference.

But when I press to go back, the screen turns totally white and soon follows the desired stream. This problem only occurs in android versions 8.0 +.

Follows the OnOptionsItemsSelected servant:

case Android.Resource.Id.Home:
                DroidApplication.current.navigation.StartActivity(ownerActivity, DroidApplication.current.CurrentTypeActivity);
                return true;

                default:
                return base.OnOptionsItemSelected(item);

Follows the StartActivity:

 public void StartActivity(Activity activity, Type activityDestino, Dictionary<string, object> prefs)
    {
        StartActivity(activity, new Intent(activity, activityDestino), prefs);
    }

    public void StartActivity(Activity activity, Type activityDestino)
    {
        StartActivity(activity, new Intent(activity, activityDestino), null);
    }

    public void StartActivity(Activity activity, Intent intent, Dictionary<string, object> prefs)
    {
        int animationIn = Resource.Animation.fade_in;
        int animationOut = Resource.Animation.fade_out;

        StartActivity( activity, intent, animationIn, animationOut, prefs);
    }

    public void StartActivity(Activity activity, Intent intent, int animationIn, int animationOut, Dictionary<string, object> prefs)
    {
        SavePreferences(activity, prefs);
        intent.AddFlags(ActivityFlags.NoAnimation);
        intent.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop);
        activity.StartActivity(intent);
        //activity.OverridePendingTransition(animationIn, animationOut);
    }

When I starto one activity, no problem occurs and I use the same method:

Example:

else if (codigoAcao == CODIGO_ACAO_ACTIVITY_MAIN)
        {
            DroidApplication.retornarInicial = false;
            StartActivity(activity, typeof(MainActivity));
        }

1 answer

1

I managed to solve my problem...

When I used to use it:

 intent.AddFlags(ActivityFlags.NoAnimation);
 intent.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop);

The whole stack of activities was cleaned. This caused my references to be lost and when I returned to Antarctica, I would have to reload it... This time of creation of the screen turned white and only after the layout appeared... So the solution was to remove those lines of code that were solved.

  • 1

    You only need to remove this Intent.Addflags(Activityflags.Newtask | Activityflags.Cleartop); Flag Noanimation does not need to remove.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.