package org.jivesoftware.smack;

import org.jivesoftware.smack.util.DNSUtil;
import org.jivesoftware.smack.util.dns.DNSJavaResolver;
import org.xbill.DNS.ResolverConfig;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;

public class SmackAndroid {
	private static SmackAndroid sSmackAndroid = null;

	private BroadcastReceiver mConnectivityChangedReceiver = new BroadcastReceiver() {
		@Override
		public void onReceive(Context context, Intent intent) {
			ResolverConfig.refresh();
		}
	};

	private static boolean receiverRegistered = false;
	private Context mCtx;

	private SmackAndroid(Context ctx) {
		mCtx = ctx;
		DNSUtil.setDNSResolver(DNSJavaResolver.getInstance());
	}

	/**
	 * Init Smack for Android. Make sure to call
	 * SmackAndroid.onDestroy() in all the exit code paths of your
	 * application.
	 */
	public static synchronized SmackAndroid init(Context ctx) {
		if (sSmackAndroid == null) {
			sSmackAndroid = new SmackAndroid(ctx);
		}
		sSmackAndroid.maybeRegisterReceiver();
		return sSmackAndroid;
	}

	/**
	 * Cleanup all components initialized by init(). Make sure to call
	 * this method in all the exit code paths of your application.
	 */
	public synchronized void onDestroy() {
		if (receiverRegistered) {
			mCtx.unregisterReceiver(mConnectivityChangedReceiver);
			receiverRegistered = false;
		}
	}

	private void maybeRegisterReceiver() {
		if (!receiverRegistered) {
			mCtx.registerReceiver(mConnectivityChangedReceiver, new IntentFilter(
					ConnectivityManager.CONNECTIVITY_ACTION));
			receiverRegistered = true;
		}
	}
}

@@ -26,16 +26,50 @@
 smack;%0A%0A
+import java.util.logging.Logger;%0A%0A
 import o
@@ -104,16 +104,16 @@
 NSUtil;%0A
-
 import o
@@ -409,16 +409,103 @@
 droid %7B%0A
+%09private static final Logger LOGGER = Logger.getLogger(SmackAndroid.class.getName());%0A%0A
 %09private
@@ -702,16 +702,97 @@
 tent) %7B%0A
+%09%09%09LOGGER.fine(%22ConnectivityChange received, calling ResolverConfig.refresh()%22);%0A
 %09%09%09Resol
@@ -1531,24 +1531,94 @@
 Destroy() %7B%0A
+%09%09LOGGER.fine(%22onDestroy: receiverRegistered=%22 + receiverRegistered);%0A
 %09%09if (receiv
@@ -1730,16 +1730,16 @@
 %09%09%7D%0A%09%7D%0A%0A
-
 %09private
@@ -1766,24 +1766,106 @@
 eceiver() %7B%0A
+%09%09LOGGER.fine(%22maybeRegisterReceiver: receiverRegistered=%22 + receiverRegistered);%0A
 %09%09if (!recei

Add JUL to SmackAndroid