E.F.
I think you are probably right - he's most likely doing it for attention. If it were me, I'd try and ignore that behavior and focus on other things that he does that you can praise him for. I've also noticed that when my daughter starts acting out and doing negative attention getting behaviors, it's the times when I've been really preoccupied with other things and not really giving her enough one on one time, so you might consider that too.