I had this exact problem plaguing me for a while and I even replaced the micro sd card reader / SIM card tray. That worked for only one day. After closely looking at the motherboard I found the issue. My phone has worked flawlessly ever since.
The adhesive tape on the back of the SIM card holder is not strong enough. It comes ever so slightly loose on the side where the SD CARD is (the left side). I took a thin piece of plastic, thinner than a credit card, cut it to approximately 1/2" x 1" and placed it over the SD CARD tray with the long part in the direction facing the top of the phone. Then I reassembled the phone. This causes the the micro sd card reader / SIM card tray to make constant contact. Fixed!
I'm sure I could take some photos if needed. One is attached.
I hope this helps as this seems to be a common problem with the S4 and it seems like it may be a design defect. It is most definitely NOT a software issue.
The adhesive tape on the back of the SIM card holder is not strong enough. It comes ever so slightly loose on the side where the SD CARD is (the left side). I took a thin piece of plastic, thinner than a credit card, cut it to approximately 1/2" x 1" and placed it over the SD CARD tray with the long part in the direction facing the top of the phone. Then I reassembled the phone. This causes the the micro sd card reader / SIM card tray to make constant contact. Fixed!
I'm sure I could take some photos if needed. One is attached.
I hope this helps as this seems to be a common problem with the S4 and it seems like it may be a design defect. It is most definitely NOT a software issue.