Code Walkthrough:
Main Activity Create Event (when the app is created)
- The app is created
- The default layout is set
- Get the phone's ringer state (Normal, Silent, or Vibrate)
- Set up buttons so they change the ringer mode when pressed
Main Activity On Resume Event (when the app is re-opened after using a different app)
- Get the phone's ringer state (in case it changed)
- Refresh screen to display the correct image (See Refresh Screen)
Silent Button On Click Event (when the button on the left is pressed)
- If the phone is in silent mode, set it back to normal mode, else set it to silent mode
- Refresh screen to display changes (See Refresh Screen
Vibrate Button On Click Event (when the button on the right is pressed)
- If the phone is in vibrate mode, set it back to normal mode, otherwise set it it to vibrate mode
- Refresh screen to display changes (See Refresh Screen)
Refresh Screen:
- Set the image to match the current mode
- Change the button text so the two buttons correspond to the other two ringer modes other than the current mode:
- If in silent mode, the buttons read "Normal" and "Vibrate"
- If in vibrate mode, the buttons read "Silent" and "Normal"
- If in normal mode, the buttons read "Silent" and "Vibrate"
Screenshots:




No comments:
Post a Comment