xprintidle doesn't work in cronjob. Why?

You need to set the DISPLAY environment variable before calling it, you can try this in the virtual consoles (Ctrl-Alt-F1) since they don't have the DISPLAY variable set, they will act exactly like the cron script will act.

DISPLAY=:0 xprintidle

or

export DISPLAY=:0
xprintidle

either should work.