如何解决从空白屏幕上的空白屏幕推入打开时,Android应用停止
当我收到推送通知并单击它时,我的应用程序打开并在空白屏幕上停止,只有空白工具栏。
它并不总是发生,仅当应用长时间在后台运行且未被系统杀死时才会发生。 单击正在运行的应用程序并选择我的应用程序仅有助于继续加载
当应用终止运行并从寒冷中打开时,它可以正常工作。当应用程序最近合拢时,它也可以正常工作,并可以通过推送打开
谢谢
Activity attributes:
[MvxActivityPresentation]
[Activity(
AlwaysRetainTaskState = true,Label = "MyPushApp",LaunchMode = LaunchMode.SingleTop,Theme = "@style/Theme.MyTheme",ScreenOrientation = ScreenOrientation.User)]
public class MainActivity : ExtendedDrawerActivity<MenuVM>,ITabletActivity
Activity OnResume():
protected override void OnResume()
{
base.OnResume();
if (ViewModel.InitializeTask.IsSuccessfullyCompleted && CheckIntentForPushNotification())
{
ViewModel.PushReceived = false;
OpenPushNotification();
}
CheckIntentForPushNotification():
protected bool CheckIntentForPushNotification()
{
return Intent != null && Intent.Extras != null && (Intent.HasExtra(MyFirebaseMessagingService.NotificationBodyTag) || Intent.HasExtra(CheckNotificationsService.LocalNotificationTag));
}
OpenPushNotification():
private void OpenPushNotification()
{
if (ViewModel.PushReceived || Intent == null)
{
_log.Info("ViewModel.PushReceived || Intent == null");
return;
}
if (Intent.HasExtra(MyFirebaseMessagingService.NotificationBodyTag))
{
string notificationText = Intent.GetStringExtra(MyFirebaseMessagingService.NotificationBodyTag);
string objIds = Intent.GetStringExtra(MyFirebaseMessagingService.ObjectIdTag);
string objType = Intent.GetStringExtra(MyFirebaseMessagingService.ObjectTypeTag);
string objSubtype = Intent.GetStringExtra(MyFirebaseMessagingService.ObjectSubtypeTag);
string moduleType = Intent.GetStringExtra(MyFirebaseMessagingService.ModuleTypeTag);
string notificationType = Intent.GetStringExtra(MyFirebaseMessagingService.NotificationTypeTag);
string folderId = Intent.GetStringExtra(MyFirebaseMessagingService.FolderIdTag);
List<int> ids = objIds?.Split(',')?.Select(id => int.Parse(id))?.ToList();
Mvx.IoCProvider.Resolve<IMvxMessenger>().Publish(new MainPushMessage(this)
{
Text = notificationText,AppLaunchedByNotification = _startWithNotification,NotificationTypeId = string.IsNullOrEmpty(notificationType) ? 0 : Int32.Parse(notificationType),FolderId = string.IsNullOrEmpty(folderId) ? 0 : Int32.Parse(folderId),ObjectIds = ids ?? new List<int>(),ObjectType = objType,ObjectSubtype = objSubtype,});
}
if (Intent.HasExtra(CheckNotificationsService.LocalNotificationTag))
{
Mvx.IoCProvider.Resolve<IMvxMessenger>().Publish(new MainPushMessage(this)
{
IsLocalNotification = true
});
}
Intent = null;
}
Activity OnNewIntent():
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
Intent = intent;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。