We still occasionally have issues with our 5 year old. She'll be in the car with us for a 2 hour ride, and be dry and tell us she has to go potty, but she'll get engrossed in a Backyardigans episode, and then potty in her pants. It's just so frustrating because it's really all up to them - it's their body, and they should "know" when they have to "go".
The thing we do that works best is: Any time she wants to do anything, "Go potty first." For him, I'd modify that to, "Go poop first." Doesn't matter what he's asking for - time on the computer, to play a game, to go outside and play, whatever...anything he asks for, the response is the same: "Go poop first, then we can do what you want to do."
Just the other night, we were at a restaurant with a play-place in it. The mother asked the 2 year old (who looked older than my 2 year old who turned 2 a couple weeks ago) as they were going into the play-place, "Do you have to go potty?" He just sat there and wouldn't answer her despite repeated questions until I looked over at him and said, "Yes or no, buddy?" He said no. Not more than 5 minutes later, I took my 2 year old to change her diaper, and while in the bathroom tending to the stinky diaper, she came in with her son with him saying, "But I don't want to go home" and she grumbled, "We may not have a choice since you pooped in your pants." I called out that I had wipes; she said she didn't need any, but I was just laughing to myself the whole time from when she asked him if he had to go potty. You never ask if they have to go potty. You tell them, "Let's go potty first, and then we can go play." The crisis still may not have been averted, but by doing it that way, you're putting the odds in your favor that they'll potty in the potty rather than their pants that way.
The only other thing that came to mind was I saw a Dr. Phil show where a mom who was having trouble disciplining their child - they'd put him in time out and he'd potty in his pants to get out of it. He told her to grab a garbage bag, and use duct-tape to make a "make shift diaper" and let him stew in it. Of course, she said, "Oh I can't do that...." He said, "Sure you can." They kept the camera's in the house, and the next time that happened, she did it. Only took once, and it never happened again. Admittedly this is a slightly different situation.
For what it's worth, and good luck!