Android allows for a lot of things to be automated, though some of them require the device to be rooted. While it can do some things itself with more recent versions (e.g. switching to an energy-saving mode when your battery runs low), the real interesting stuff requires a third-party-app – of which again are plenty available.
So if your question is about how to automate something, without a specific app/solution in mind, the automation tag should be used. But before applying it to your question, please check if we don't have a better match:
- tasker: the most extensive and flexible app in this field. Up to now, no other app can hold a candle to it.
- llama: a free alternative to Tasker. By far not that mighty, but sufficient for many cases/users.
- locale: one of the first automation solutions. Quite easy to use, but not as powerful as... Tasker :)