Android widget creation with status display and command

I need to create a widget on Android to drive a Boolean input.
How can I do?