Instead of having four if conditions here, two of which repeat, let's replace intent.getAction().equals() with isIncomingSmsAction() that just returns (SMS_RECEIVED && !isDefaultSmsApp) || (SMS_DELIVER && isDefaultSmsApp)