There is a tutorial on Android Developer website which guides you on how to create a custom notification.It works great on most of the android devices however some branded phone of motorola (Motorola Electrify) have their own dismiss button.I guess that this firmware/ROM of android overrides the default XML layout of the default notification. thus, a custom notification does not have this dismiss button.

Is there an easy way to keep this button? or the only way is to check whether that this device have such a button and if so add one?
By definition, no, since you did not put the button there in the first place.
I have no idea how you would do that.
I have no idea how you would do that either. For devices that lack per-
Notificationdismiss options (Android 1.x/2.x), you cannot have a button of your own. You can always have yourNotificationbe set for auto-cancel (e.g.,setAutoCancel(true)withNotification.Builder), in which case tapping anywhere on theNotificationwill dismiss it.