A dog usually displays certain behaviors immediately prior to toileting. These include sniffing around and sidling up to objects. As soon as you spot these telltale signs, take him out. It can help to keep him on a leash so that you can keep a closer eye on him. Watch carefully, and you'll soon start to understand the subtle body language which indicates he needs to toilet.