private void unRegisterForServiceStateChanges() { if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE) || LogTag.DEBUG_SEND) { Log.v(TAG, "unRegisterForServiceStateChanges"); } try { Context context = getApplicationContext(); context.unregisterReceiver(SmsReceiver.getInstance()); } catch (IllegalArgumentException e) { // Allow un-matched register-unregister calls } }
private void registerForServiceStateChanges() { Context context = getApplicationContext(); unRegisterForServiceStateChanges(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE) || LogTag.DEBUG_SEND) { Log.v(TAG, "registerForServiceStateChanges"); } context.registerReceiver(SmsReceiver.getInstance(), intentFilter); }