开发者

Resuming Android app from an ongoing notification

开发者 https://www.devze.com 2023-03-31 03:50 出处:网络
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 d

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 f开发者_如何学Pythonor 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.


I currently use (in my countdown app):

android:launchMode="singleTask"
0

精彩评论

暂无评论...
验证码 换一张
取 消