我在我的Android应用程序中执行状态栏通知,由c2dm触发.如果应用程序正在运行,我不想显示通知.您如何确定应用程序是否正在运行且位于前台?
我向用户发送推送通知,点击它时会打开应用程序.
我的问题是,当应用程序已经打开时,单击通知会再次启动应用程序.
我只希望它启动应用程序,如果它还没有运行.
我在通知中使用Pending Intent:
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, Splash.class), 0);
Run Code Online (Sandbox Code Playgroud)
我看到帖子说使用:
<activity
android:name=".Splash"
android:launchMode="singleTask"
Run Code Online (Sandbox Code Playgroud)
但问题是我正在运行的应用程序正在运行其他活动,然后启动应用程序启动后7秒内完成,因此当应用程序运行时,Splash不是当前活动
notifications android push-notification android-pendingintent