Detecting application hide and restore states?

Dear all,
I wrote a simple game and published it to android successfully.
I need to do now 2 things:
1- Know when user click on home button and the game hide.
2- Know when the user click on the game from the applications list and game restore.
Any idea?

There is a callback for this as far as i know. Take a look here