Prayer is the second pillar of Islam after testifying that there is no God, but Allah and that Muhammad is the Messenger of Allah. It is the cornerstone of Islam and the key to Paradise. So, Muslims must pay due attention to this great act of worship. They should stay away from any distractions that may reduce their rewards or affect the concentration of people praying.
Sheikh Ahmad Kutty, a senior lecturer and Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, states: Prayer is the most important act that we can ever hope to perform in this world: It is the celebration of remembrance of Allah, our Creator and Sustainer; our sure connection with Him; and our key to salvation and eternal bliss. Prophet Muhammad (peace and blessings be upon him) said, “A person in prayer is communing with his [or her] Lord, so let each be very careful how he [or she] is communing with Allah” (At-Tabarani).
It is therefore imperative that we enter Prayer in a state of utter concentration and presence of mind. In order to attain this goal, it is only proper of us to do everything possible within our means to dispel all distracting thoughts and keep away all those things that may decrease or affect our concentration. Thus, we ought to switch off our cell phones and other devices, if at all we are taking them with us to Prayer. It is even better that we do not take them along with us to Prayer. For the Prophet (peace and blessings be upon him) said, “Remember that in Prayer every one is communing with his [or her] Lord, so let no one distract another by reading the Qur’an aloud” (Al-Bukhari). If we are not supposed to distract one another even by reciting the Qur’an, we need not mention other types of distractions.
This said, if you happened to carry your cell phone to the Prayer hall and it rang, you must switch it off immediately. By failing to do so, you are not only distracting yourself but also everyone else in the congregation.
This single act alone would not render you Prayer invalid, but the issue is different if you keep on doing it often: According to scholarly consensus, repeating such acts often would definitely render the Prayer as invalid. I would therefore insist that you do not take such devices to the Prayer Hall; if you have to, then you must never forget to turn them off. It would constitute an offence not to do so.
May Allah inspire us to take salah seriously and may He instill in our hearts a true sense of reverence for Him, amen.