Fix potential NPE when the connection is not created yet when the service is
authorDa Risk <da_risk@beem-project.com>
Mon, 15 Jun 2015 14:04:24 +0200
changeset 1062 b9445d741660
parent 1061 3ad94aed2c26
child 1063 2514466a0614
Fix potential NPE when the connection is not created yet when the service is destroyed
app/src/main/java/com/beem/project/beem/BeemService.java
--- a/app/src/main/java/com/beem/project/beem/BeemService.java	Fri May 01 01:36:53 2015 +0200
+++ b/app/src/main/java/com/beem/project/beem/BeemService.java	Mon Jun 15 14:04:24 2015 +0200
@@ -287,6 +287,7 @@
 	mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
 
 	Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
+
 	mBind = new XmppFacade(this);
 	Log.d(TAG, "Create BeemService");
     }
@@ -302,7 +303,7 @@
 	mSettings.unregisterOnSharedPreferenceChangeListener(mPreferenceListener);
 	if (mOnOffReceiverIsRegistered)
 	    unregisterReceiver(mOnOffReceiver);
-	if (mConnection.isAuthentificated() && BeemConnectivity.isConnected(this))
+	if (mConnection != null && mConnection.isAuthentificated() && BeemConnectivity.isConnected(this))
 	    mConnection.disconnect();
 	Log.i(TAG, "Stopping the service");
     }