Flowdalic/asmack — pull request #16 by Javran (2012-10-31 02:38:44+00:00)
Title: Add receiver register/unregister control on SmackAndroid so that it can be reused

I use asmack lib as a bound service, put SmackAndroid.init() in onCreate, and use SmackAndroid.init().exit() in onDestroy() to prevent a "Leaked IntentReceiver" exception.

However I found that once SmackAndroid.init().exit() was called, it cannot be initialized again using SmackAndroid.init() because we cannot re-register "mConnectivityChangedReceiver" and if a second corresponding SmackAndroid.init().exit() was called, my app will throw an exception because "mConnectivityChangedReceiver" had been unregistered.

So I add some register/unregister control:

`SmackAndroid.init(Context)` will initialize asmack and ensure receiver's register as usual.
`SmackAndroid.exit()` will unregister receiver safely.

With those changes SmackAndroid can be reused after SmackAndroid.exit() has been called.