当我点击通知时我想继续应用程序,而不是开始一个意图

when I clicked notification I want to continue app , not start an intent

我有一个 Service 用于侦听套接字并在数据到达时创建通知。当用户单击开始 MainActivity 的通知时,但我不想启动意图,我只想打开应用程序并继续。因为我在 MainActivity 中显示了一张地图,当我开始 MainActivity 时它会再次触发 OnMapReady 函数。

您必须寻找 android:launchMode 标签。请参考此页面:activity-element

例如在您的 AndroidManifest.xml 中:

<activity
    android:name=".activity.YasinActivity"
    android:configChanges="screenLayout|screenSize|orientation"
    android:label="blabla"
    android:launchMode="singleTask"
    android:theme="@style/AppTheme"
    android:windowSoftInputMode="stateAlwaysHidden" />

尝试将此标志添加到您的 PendingIntent PendingIntent.FLAG_UPDATE_CURRENT

例如:

PendingIntent.getActivity(this, 0, new Intent(this, YourActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);

如果应用程序有背景,它会在不重新加载的情况下打开您的应用程序,当您的应用程序被销毁时,它会重新加载应用程序。