Assalamualaikum w.b.t. How can one prevent or stops the shaytan or jinn from looking at his awrah especially in situations when he needs to unclothe such as taking a shower, changing or urinating? Hope for an explanation.
Alhamdulillah, praise and gratitude to Allah SWT for His countless blessings for us all. Praise and salutations to our beloved Prophet Muhammad PBUH, his family, companions and all those who follow his footsteps until the Last Day.
We’ll begin with the statement of Allah SWT:
إِنَّهُ يَرَاكُمْ هُوَ وَقَبِيلُهُ مِنْ حَيْثُ لَا تَرَوْنَهُمْ ۗ إِنَّا جَعَلْنَا الشَّيَاطِينَ أَوْلِيَاءَ لِلَّذِينَ لَا يُؤْمِنُونَ
“Indeed, he sees you, he and his tribe, from where you do not see them. Indeed, We have made the devils allies to those who do not believe.” 
Generally, this verse clearly shows that the jinn and shaytan can see the awrah of the children of Adam. Likewise, this matter is strengthened with hadiths that contain the commandments to recite basmalah when unclothing or entering the bathroom to protect himself from the eyes of the shaytan. The reason is if this is not so, there is no reason for the commandment to be mentioned in the hadith. We’ve also discussed this matter in-depth in our previous article titled: #472 The Jinn and Shaytan Can See People’s Awrah. 
Coming back to the question presented, first, the Prophet PBUH taught us to always precede our every action with supplication and basmalah. This matter is mentioned through the hadiths, among them is a narration from Anas bin Malik RA where Rasullullah PBUH said:
سِتْرُ مَا بَيْنَ أَعْيُنِ الْجِنِّ، وَعَوْرَاتِ بَنِي آدَمَ إِذَا وَضَعُوا ثِيَابَهُمْ أَنْ يَقُولُوا : بِسْمِ اللَّهِ
“The screen – that is the barrier – between the eyes of the jinn and the awrah of the Bani Adam when they are changing their clothes is the recitation of basmalah.” 
Furthermore, there is another narration from Ali bin Abu Talib where Rasullullah PBUH said:
سِتْرُ مَا بَيْنَ الْجِنِّ وَعَوْرَاتِ بَنِي آدَمَ إِذَا دَخَلَ الْكَنِيفَ أَنْ يَقُولَ: بِسْمِ اللَّهِ
“The screen between the Jinn and the nakedness of the sons of Adam is that when a person enters the Kanif (bathroom), he should say: Bismillah (in the name of Allah).” 
Regarding this matter, al-Mubarakfuri cited the opinion of al-Munawi who said, the reason for the need to recite basmalah is due to the fact the name of Allah SWT is just like a lock for the children of Adam where the jinn and shaytan are unable to unlock.  Furthermore, Sa’id bin Ali Wahf al-Qahtani also stated that the recitation of basmalah when one is about to enter the bathroom when partially or completely taking off your clothes for certain reasons in the bathroom is instructed by the shariah as mentioned in the narration of Ali RA. The wisdom is to ask the help of Allah SWT so that one is protected from the jinn and shaytan from looking at the awrah of the children of Adam when they are urinating or defecating or taking off their clothes. 
The same is commanded for a husband to recite basmalah even in the matters of having intercourse with his wife. This is based on a hadith narrated by Ibn Abbas R.anhuma where Rasullullah PBUH said:
لَوْ أَنَّ أَحَدَكُمْ إِذَا أَتَى أَهْلَهُ قَالَ بِسْمِ اللَّهِ اللَّهُمَّ جَنِّبْنَا الشَّيْطَانَ وَجَنِّبِ الشَّيْطَانَ مَا رَزَقْتَنَا فَقُضِيَ بَيْنَهُمَا وَلَدٌ، لَمْ يَضُرَّهُ
“If anyone who means to have intercourse with his wife says, “In the name of God. O God, keep us away from the devil and keep the devil away from what Thou hast provided us,” should it be ordained that a child be born to them thereby, no devil will ever harm it.” 
Al-Hafiz Ibn Hajar al-‘Asqalani said that among the wisdoms from this hadith is the encouragement to recite basmalah, supplicate and take care of such matters that improve the relationship of husband and wife. Moreover, it depicts to us that the shaytan is always together with the children of Adam and they will not turn away from us except after we recite zikrullah. Furthermore, it also shows the commandment for a person to always seek the protection from Allah SWT from any form of evils in his worldly matters as well as the hereafter. 
Second, as Muslims, we should try our best to avoid exposing our awrah unnecessarily even when we are alone. There is a narration from Bahz bin Hakim, from his father, from his grandfather, he said:
قُلْتُ: يَا رَسُولَ اللَّهِ عَوْرَاتُنَا مَا نَأْتِي مِنْهَا وَمَا نَذَرُ؟ قَالَ: «احْفَظْ عَوْرَتَكَ إِلَّا مِنْ زَوْجَتِكَ أَوْ مَا مَلَكَتْ يَمِينُكَ»، فَقَالَ: الرَّجُلُ يَكُونُ مَعَ الرَّجُلِ؟ قَالَ: «إِنْ اسْتَطَعْتَ أَنْ لَا يَرَاهَا أَحَدٌ فَافْعَلْ»، قُلْتُ: وَالرَّجُلُ يَكُونُ خَالِيًا، قَالَ: فَاللَّهُ أَحَقُّ أَنْ يُسْتَحْيَا مِنْهُ
“O Messenger of Allah! Regarding our ‘Awrah, what of it must we cover and what of it may we leave?” He said: “Protect your ‘Awrah except from your wife or what your right hand possesses.”‘ He said: “What about a man with another man?” He said: “If you are able to not let anyone see it, then do so.” I said: “What about a man when he is alone?” He said: “Allah is most deserving of being shy from Him.” 
This is as cited by scholars of madhhab Hanafi – according to the sahih opinion – Shafiite scholars and scholars of madhhab Hanbali are of the opinion that it is obligatory to cover one’s awrah even when one is alone (in a secluded place) and far from the prying eyes of others. While according to the scholars of madhhab Maliki, it is sunnah to cover the awrah when a person is alone and it is commanded for a person to feel shy in front of Allah SWT and His angels. As for the jumhur of scholars, they argued that the commandment of covering the awrah is absolute and that Allah SWT is far more worthy for a person to be shy of as stated in the hadith of Bahz bin Hakim mentioned above. Hence, covering the awrah when a person is alone is instructed except when it is necessary such as when taking a shower, cooling off and others. 
According to the above arguments and discussions, in our opinion among the best ways to protect our awrah from being seen by the jinn and shaytan is by seeking protection from Allah SWT. The reason is that the jinn and shaytan are able to see us in any situation, whether when we are changing our clothes or taking them off, when we are defecating or urinating in the bathroom, taking a bath, eating and others. However, such matters are subject to the permission of Allah SWT. Hence, if Allah SWT doesn’t permit it, then they wouldn’t be able to see the awrah of the children of Adam.
On this basis, Rasullullah PBUH taught us supplications and commanded us to precede each of our actions with supplication and the recitation of basmalah. The reason is the recitation of basmalah is like a lock for the children of Adam which the jinn and shaytan aren’t able to unlock. Thus, first start any activity or any actions – permissible actions – with basmalah even if it is not when one is entering the bathroom or taking off one’s clothes, for the Prophet PBUH said:
كلُّ كلامٍ، أو أمرٍ ذي بالٍ لا يُفتَحُ بذِكْرِ اللَّهِ عزَّ وجلَّ فَهوَ أبترُ
“Any action that isn’t preceded with the mention of the name of Allah (zikrullah), then the action is broken.” 
Furthermore, we’d also like to advise all of us to always strive to avoid exposing our awrah unnecessarily even when we are alone. Next, remember that as Muslims, we are slaves of Allah SWT who always oversees us in every situation. Allah SWT oversees us and only to Him do we ask for help. This is the evidence of the perfection of the shariah of this religion, which includes manners that every Muslim should learn and be mindful of – firmly believe in them and practise them – including all day and night activities.
There are also other supplications that can be applied in the daily lives that can protect us from the eyes of the jinn and shaytan and their evil deeds. Hence, we suggest our readers refer to books that compiled such supplications as Hisnul Muslim or the Shield of Muslims that have been translated or other collections of supplication books and others.
May Allah SWT grant us all a clear understanding of religion. Ameen.
 Surah al-A‘raf: 27
 See https://maktabahalbakri.com/472-jin-dan-syaitan-dapat-meSee-aurat-manusia/. Accessed on 15th February 2022.
 Narrated by al-Tabarani in al-Mu‘jam al-Ausat (2504)
 Narrated by Ibn Majah (297); al-Tirmizi (606) with slight differences.
 See Tuhfah al-Ahwazi, 3/184.
 See Ithaf al-Muslim bi Syarhi Husni al-Muslim, pg. 103.
 Narrated by al-Bukhari (141)
 See Fath al-Bari, 9/136.
 Narrated by al-Tirmizi (2769)
 See Mausu‘ah al-Fiqhiyyah al-Kuwaitiyyah, 24/176.
 Narrated by Ahmad (8712)