To automatically connect to a Wi-Fi network when launching applications

From the Home screen, tap the Menu Key > Settings > Wi-Fi.

Or you can just tap the Wi-Fi icon from the Notifications panel to turn on Wi-Fi.

From the Wi-Fi settings screen, tap Optimize Wi-Fi usage for the following settings: