简体   繁体   English

从后台启动应用程序时会调用onNewIntent

[英]onNewIntent is called when app is launched from background

I have a singleTop activity, this activity is launched via Intent : 我有一个singleTop活动,该活动是通过Intent启动的:

    Intent intent = new Intent(GCMIntentService.this,MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

onNewIntent is called. onNewIntent被调用。

My problem is that then I hit home button, and then launch application again (from background) onNewIntent is called again with the same intent, and I can not find a way to discard this Intent . 我的问题是,然后单击主页按钮,然后再次从后台启动应用程序(使用后台),以相同的意图再次调用onNewIntent ,而我找不到找到丢弃此Intent I tried to putExtra flag to this intent, but it is not persisted between application state changes. 我尝试将putExtra标志用于此目的,但在应用程序状态更改之间不持久存在。

Is it possible to stop calling onNewIntent() when application comes to foreground? 当应用程序进入前台时,是否可以停止调用onNewIntent()

在清单中,将以下行添加到MainActivity

android:finishOnTaskLaunch="true"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 先前从通知启动应用程序时,Android上的FCM不会触发`onNewIntent` - FCM on Android does not trigger `onNewIntent` when app was previously launched from notification Xamarin- MainActivity.OnNewIntent 在单击时应用程序处于后台时使用错误的参数调用推送通知 - Xamarin- MainActivity.OnNewIntent called with wrong parameters for Push Notification when App is in Background when Clicked Android SearchView 既未启动可搜索活动,也未调用 onNewIntent() - Android SearchView neither searchable activity launched nor onNewIntent () called onNewIntent 没有被调用 - onNewIntent is not called 当顶部还有另一个活动时,不会调用onNewIntent() - onNewIntent() not being called when there is another activity on top 扫描NFC标记时,不会调用onNewIntent方法 - onNewIntent Method is not called when NFC Tag is scanned 从锁定屏幕点击通知时不会调用 OnNewIntent。 当通知点击锁屏时,意图未通过 - OnNewIntent not called when notification is hit from lock screen. And intent not passed when notification clicked on lockscreen 启动时未调用的方法 - Method not called when launched 从后台启动混合Android应用程序时HTTP调用中的异常行为 - Weird behaviour in HTTP call when hybrid Android app is launched from background 我的应用程序在 onNewintent() 执行时崩溃 - My app crashes when onNewintent() executes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM