From 80d897ba36d91eea9dc26c75daa58685350e01f0 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 12 May 2014 16:08:41 +0200 Subject: [PATCH] Hopefully fixed crash in RemotePlayService#sendMessage, minor refactoring. --- .../nutomic/controldlna/upnp/RemotePlayService.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/github/nutomic/controldlna/upnp/RemotePlayService.java b/src/main/java/com/github/nutomic/controldlna/upnp/RemotePlayService.java index 1108f33..48f187f 100644 --- a/src/main/java/com/github/nutomic/controldlna/upnp/RemotePlayService.java +++ b/src/main/java/com/github/nutomic/controldlna/upnp/RemotePlayService.java @@ -74,9 +74,9 @@ public class RemotePlayService extends Service implements RegistryListener { private static final String TAG = "RemotePlayService"; - Messenger mListener; + protected Messenger mListener; - ConcurrentHashMap> mDevices = + protected ConcurrentHashMap> mDevices = new ConcurrentHashMap>(); protected AndroidUpnpService mUpnpService; @@ -144,11 +144,15 @@ public class RemotePlayService extends Service implements RegistryListener { * Sends msg via Messenger to Provider. */ void sendMessage(Message msg) { + if (mListener == null) { + Log.w(TAG, "Listener is not initialized on send"); + } + try { mListener.send(msg); } catch (RemoteException e) { - e.printStackTrace(); + Log.w(TAG, "Failed to send message", e); } }