FirebasePushNotificationPlugin
FirebasePushNotificationPlugin copied to clipboard
Prevent restart when app is running
Hello I would like to consult about a issue. When I am clicking to the received notification from Android statusbar when my application is running on foreground or background. Application does not appear. it restart itself instead of appear. I would like to just appear when my app is running. is there any way to achieve that? Thank you in advance.
I have the same problem
Hi all, that is something I resolved with this code in SplashScreen if you have it,
protected override void OnCreate(Bundle savedInstanceState) {
base.OnCreate(savedInstanceState);
var mainIntent = new Intent(Application.Context, typeof(MainActivity));
if (Intent.Extras != null)
{
mainIntent.PutExtras(Intent.Extras);
}
if (someFlag)
{
// to avoid restart the app
mainIntent.SetFlags(ActivityFlags.SingleTop);
}
else
{
// to restart the app
mainIntent.SetFlags(ActivityFlags.ClearTop);
}
StartActivity(mainIntent);
}
Regards
Thank you very much, I made this change and it worked.
public class SplashActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
var mainIntent = new Intent(Application.Context, typeof(MainActivity));
if (Intent.Extras != null)
{
mainIntent.PutExtras(Intent.Extras);
}
mainIntent.SetFlags(ActivityFlags.SingleTop | ActivityFlags.ClearTop);
StartActivity(mainIntent);
}
}
Hi all, that is something I resolved with this code in SplashScreen if you have it,
protected override void OnCreate(Bundle savedInstanceState) {
base.OnCreate(savedInstanceState); var mainIntent = new Intent(Application.Context, typeof(MainActivity)); if (Intent.Extras != null) { mainIntent.PutExtras(Intent.Extras); } if (someFlag) { // to avoid restart the app mainIntent.SetFlags(ActivityFlags.SingleTop); } else { // to restart the app mainIntent.SetFlags(ActivityFlags.ClearTop); } StartActivity(mainIntent);
}
Regards
Thank you very much it is working for me too.