简体   繁体   中英

Resuming Android app from an ongoing notification

I am working with notifications for the first time, and it seems that i must be missing something obvious. I have an Android app that plays music. While it is playing, I have an ongoing notification displayed so I can easily get back to my app if it is in the background. My problem is that when I click the notification, it opens a whole new instance of the application, instead of resuming the previous instance.

I have a PendingIntent set up to launch my app, and a call to PendingIntent.getActivity(context, 0,myIntent, 0) I've tried different settings for the last parameter, but same results. What am I missing?

Mark D.

You should edit your Activity's entry in the AndroidManifest.xml to include android:launchMode (see here for the options). Most likely will be anything but standard . Also see if playing around with this and or this may help.

我目前使用(在我的倒计时应用程序中):

android:launchMode="singleTask"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM