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));
}
You only need to remove this Intent.Addflags(Activityflags.Newtask | Activityflags.Cleartop); Flag Noanimation does not need to remove.
– perozzo