[英]Bring Android app's previous instance to foreground from FCM notification
On my app I have a Splash Screen set with intent: 在我的应用程序中,我设置了一个启动画面,其意图是:
<activity
android:name=".Splash"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
My app then opens a ".MainActivity", which is where all the action happens. 然后,我的应用程序打开一个“ .MainActivity”,这是所有操作发生的地方。 Although when I get a push FCM notification and tap it, the app restarts and I get a new instance of everything.
尽管当我收到推送FCM通知并点击它时,该应用程序将重新启动,并且我得到了一个新的实例。 How do I keep the same instance of the app but just bring it to the foreground, basically like iOS does.
我该如何保持应用程序的相同实例,而只是像iOS一样将其置于前台。
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
If FLAG_ACTIVITY_SINGLE_TOP is set, the activity will not be launched if it is already running at the top of the history stack. 如果设置了FLAG_ACTIVITY_SINGLE_TOP ,则该活动如果已在历史记录堆栈的顶部运行,则不会启动。
Referenced from: How to use Flags in android ? 引用自: 如何在Android中使用Flags?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.