@@ -248,6 +248,9 @@ private void cancleNotification() {
248248 *
249249 */
250250 private void initialize () {
251+ if (getUpnpClient () == null ) {
252+ setUpnpClient (new UpnpClient ());
253+ }
251254 if (!getUpnpClient ().isInitialized ()) {
252255 getUpnpClient ().initialize (getApplicationContext ());
253256 watchdog = false ;
@@ -264,7 +267,7 @@ public void run() {
264267 }
265268
266269 }
267- if (getUpnpClient ().isInitialized ()) {
270+ if (getUpnpClient () != null && getUpnpClient () .isInitialized ()) {
268271 if (preferences .getBoolean (getApplicationContext ().getString (R .string .settings_local_server_provider_chkbx ), false )) {
269272 if (localServer == null ) {
270273 localServer = createMediaServerDevice ();
@@ -426,11 +429,11 @@ private void startUpnpAliveNotifications() {
426429 public void run () {
427430 Log .v (YaaccUpnpServerService .this .getClass ().getName (), "Sending upnp alive notivication" );
428431 SendingNotificationAlive sendingNotificationAlive ;
429- if (localServer != null ) {
432+ if (localServer != null && getUpnpClient () != null ) {
430433 sendingNotificationAlive = new SendingNotificationAlive (getUpnpClient ().getRegistry ().getUpnpService (), localServer );
431434 sendingNotificationAlive .run ();
432435 }
433- if (localRenderer != null ) {
436+ if (localRenderer != null && getUpnpClient () != null ) {
434437 sendingNotificationAlive = new SendingNotificationAlive (getUpnpClient ().getRegistry ().getUpnpService (), localRenderer );
435438 sendingNotificationAlive .run ();
436439 }
@@ -448,6 +451,9 @@ public void run() {
448451 * @return the time
449452 */
450453 private int getUpnpNotificationFrequency () {
454+ if (getUpnpClient () == null ) {
455+ return -1 ;
456+ }
451457 return Integer .parseInt (preferences .getString (getUpnpClient ().getContext ().getString (R .string .settings_sending_upnp_alive_interval_key ), "5000" ));
452458 }
453459
0 commit comments