Or maybe he had searched everyone's feelings. Remember when he first met Trunks and didn't flinch when Trunks tried to cut him with his sword? He searched Trunk's feelings and realized that he wouldn't really hit him. So, Goku's laying in bed, doesn't have much to do except wait for the medicine to kick in, so he decides to check up on his friends and see what they know about the androids. I'd say that's a perfectly capable solution.
Another thing that could have made this happen: If you have seen Bardock Father of Goku, Bardock gets the power to see the future, and for some reason so does baby Goku. Also, on Namek Goku 'Reads Krillun's mind', so who knows?