From 146bf2158c96ef44a923ee35a5a5125673b38c9b Mon Sep 17 00:00:00 2001 From: zhkailing Date: Mon, 22 Oct 2012 16:22:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E6=8B=89=E8=8F=9C=E5=8D=95=E6=9B=BF=E6=8D?= =?UTF-8?q?=A2RemoteViews=E4=B8=BAsetLatestEventInfo=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/rockbox/Helper/RunForegroundManager.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/android/src/org/rockbox/Helper/RunForegroundManager.java b/android/src/org/rockbox/Helper/RunForegroundManager.java index 5e3f38e..b04a6e2 100644 --- a/android/src/org/rockbox/Helper/RunForegroundManager.java +++ b/android/src/org/rockbox/Helper/RunForegroundManager.java @@ -27,28 +27,28 @@ public class RunForegroundManager private Handler mServiceHandler; private Intent mWidgetUpdate; private int iconheight; + public static Service gService; public RunForegroundManager(Service service) { mCurrentService = service; + gService = service; mNM = (NotificationManager) service.getSystemService(Service.NOTIFICATION_SERVICE); - RemoteViews views = new RemoteViews(service.getPackageName(), R.layout.statusbar); /* create Intent for clicking on the expanded notifcation area */ Intent intent = new Intent(service, RockboxActivity.class); intent = intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + PendingIntent contentIntent = PendingIntent.getActivity(service, 0, intent, 0); /* retrieve height of launcher icon. Used to scale down album art. */ Resources resources = service.getResources(); Drawable draw = resources.getDrawable(R.drawable.launcher); iconheight = draw.getIntrinsicHeight(); - mNotification = new Notification(); - mNotification.tickerText = service.getString(R.string.notification); + mNotification = new Notification(R.drawable.launcher, service.getString(R.string.notification), System.currentTimeMillis()); mNotification.icon = R.drawable.notification; - mNotification.contentView = views; mNotification.flags |= Notification.FLAG_ONGOING_EVENT; - mNotification.contentIntent = PendingIntent.getActivity(service, 0, intent, 0); + mNotification.setLatestEventInfo(service, "Rockbox", "Now playing...", contentIntent); try { api = new NewForegroundApi(R.string.notification, mNotification); @@ -111,6 +111,12 @@ public class RunForegroundManager mNotification.tickerText = title; else mNotification.tickerText = title+" - "+artist; + /* update Notification LatestEventInfo */ + Intent intent = new Intent(gService, RockboxActivity.class); + intent = intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + PendingIntent contentIntent = PendingIntent.getActivity(gService, 0, intent, 0); + mNotification.setLatestEventInfo(gService, title, artist, contentIntent); + Logger.i("Now playing:"+title); if (albumart != null) { /* The notification area doesn't have permissions to access the SD card. -- 1.7.9.5