diff options
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/util/Util.java | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java index 8e3d7169..f4a3dc4c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java @@ -643,7 +643,7 @@ public final class Util { handler.post(new Runnable() { @Override public void run() { - startForeground(downloadService, Constants.NOTIFICATION_ID_PLAYING, notification); + downloadService.startForeground(Constants.NOTIFICATION_ID_PLAYING, notification); } }); @@ -657,7 +657,7 @@ public final class Util { handler.post(new Runnable() { @Override public void run() { - stopForeground(downloadService, true); + downloadService.stopForeground(true); } }); @@ -762,34 +762,6 @@ public final class Util { } } - private static void startForeground(Service service, int notificationId, Notification notification) { - // Service.startForeground() was introduced in Android 2.0. - // Use reflection to maintain compatibility with 1.5. - try { - Method method = Service.class.getMethod("startForeground", int.class, Notification.class); - method.invoke(service, notificationId, notification); - Log.i(TAG, "Successfully invoked Service.startForeground()"); - } catch (Throwable x) { - NotificationManager notificationManager = (NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE); - notificationManager.notify(Constants.NOTIFICATION_ID_PLAYING, notification); - Log.i(TAG, "Service.startForeground() not available. Using work-around."); - } - } - - private static void stopForeground(Service service, boolean removeNotification) { - // Service.stopForeground() was introduced in Android 2.0. - // Use reflection to maintain compatibility with 1.5. - try { - Method method = Service.class.getMethod("stopForeground", boolean.class); - method.invoke(service, removeNotification); - Log.i(TAG, "Successfully invoked Service.stopForeground()"); - } catch (Throwable x) { - NotificationManager notificationManager = (NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE); - notificationManager.cancel(Constants.NOTIFICATION_ID_PLAYING); - Log.i(TAG, "Service.stopForeground() not available. Using work-around."); - } - } - /** * <p>Broadcasts the given song info as the new song being played.</p> */ |