diff --git a/src/org/xbmc/android/remote/business/NowPlayingPollerThread.java b/src/org/xbmc/android/remote/business/NowPlayingPollerThread.java index 462b6c5f..c3565e18 100644 --- a/src/org/xbmc/android/remote/business/NowPlayingPollerThread.java +++ b/src/org/xbmc/android/remote/business/NowPlayingPollerThread.java @@ -116,6 +116,9 @@ public Context getApplicationContext() { }; mSubscribers = new HashSet(); } + public Context getApplicationContext() { + return mControllerStub.getApplicationContext(); + } public void subscribe(final Handler handler) { // update handler on the state of affairs ManagerFactory.getControlManager(mControllerStub).getCurrentlyPlaying(new DataResponse() { diff --git a/src/org/xbmc/android/util/ConnectionFactory.java b/src/org/xbmc/android/util/ConnectionFactory.java index 046cc7a2..25d3ad51 100644 --- a/src/org/xbmc/android/util/ConnectionFactory.java +++ b/src/org/xbmc/android/util/ConnectionFactory.java @@ -115,14 +115,10 @@ public static ServiceInfo getZeroconfServiceInfo(String type, String host) { * @return A reference to the NowPlaying Poller */ public static NowPlayingPollerThread getNowPlayingPoller(Context context) { - if (sNowPlayingPoller == null) { + if (sNowPlayingPoller == null || !sNowPlayingPoller.isAlive() || sNowPlayingPoller.getApplicationContext() != context) { sNowPlayingPoller = new NowPlayingPollerThread(context); sNowPlayingPoller.start(); } - if (!sNowPlayingPoller.isAlive()){ - sNowPlayingPoller = new NowPlayingPollerThread(context); - sNowPlayingPoller.start(); - } return sNowPlayingPoller; }