The setting of the scene pattern should be quite familiar to everyone, but how do you set up a scenario pattern in Android with your own program, where you can use the system itself or customize it, but you may need to change the scenario pattern in your program when you develop some programs. This requires the setting of the scenario pattern. The following is a brief description of how the situation pattern is set up:
Get the current scenario pattern first:
Code
Copy Code code as follows:
void Getinitring (Audiomanager audio)
{
Get the initial volume of the phone and initialize the progress bar
int Volume=audio.getstreamvolume (audiomanager.stream_ring); Get Initial volume
Get the initial mode and set the icon separately
int Mode=audio.getringermode (); Get initial mode
}
Through this code, of course, you need to process it, then you can get the current situation patterns, for future settings to do a bit of preparation, and then may also know whether to set again.
Set scene mode one: only sound, no vibration:
Code
Copy Code code as follows:
void ring (Audiomanager audio) {
Audio.setringermode (Audiomanager.ringer_mode_normal);
Audio.setvibratesetting (Audiomanager.vibrate_type_ringer,
Audiomanager.vibrate_setting_off);
Audio.setvibratesetting (Audiomanager.vibrate_type_notification,
Audiomanager.vibrate_setting_off);
Toast.maketext (This, "set success!) Current for ringtones ", Toast.length_long). Show ();
}
After setting the system only sound, no vibration.
Set scene mode two: that is, there is sound and vibration:
Code
Copy Code code as follows:
void Ringandvibrate (Audiomanager audio) {
Audio.setringermode (Audiomanager.ringer_mode_normal);
Audio.setvibratesetting (Audiomanager.vibrate_type_ringer,
AUDIOMANAGER.VIBRATE_SETTING_ON);
Audio.setvibratesetting (Audiomanager.vibrate_type_notification,
AUDIOMANAGER.VIBRATE_SETTING_ON);
Toast.maketext (This, "set success!) Current for ringtones plus vibration ", Toast.length_long). Show ();
}
After this setting, there will also be vibration reminders at the time of sound.
Set Story Mode three: only vibration:
Code
Copy Code code as follows:
void vibrate (Audiomanager audio) {
Audio.setringermode (audiomanager.ringer_mode_vibrate);
Audio.setvibratesetting (Audiomanager.vibrate_type_ringer,
AUDIOMANAGER.VIBRATE_SETTING_ON);
Audio.setvibratesetting (Audiomanager.vibrate_type_notification,
AUDIOMANAGER.VIBRATE_SETTING_ON);
Toast.maketext (This, "set success!) Present for Vibration ", Toast.length_long). Show ();
}
This setting has only vibration and no sound:
Set scene mode four: Silent without vibration:
Code
Copy Code code as follows:
void Noringandvibrate (Audiomanager audio) {
Audio.setringermode (audiomanager.ringer_mode_silent);
Audio.setvibratesetting (Audiomanager.vibrate_type_ringer,
Audiomanager.vibrate_setting_off);
Audio.setvibratesetting (Audiomanager.vibrate_type_notification,
Audiomanager.vibrate_setting_off);
Toast.maketext (This, "set success!) Currently silent without vibration ", Toast.length_long). Show ();
}
The system has no sound and vibration after setting. The appropriate prompts cannot be made.
All of the above settings are the system default sound size, then we can customize the size of the sound, the answer is certainly OK. To set the size of the sound, you need to set the following function:
To increase the volume:
Copy Code code as follows:
Audio.adjustvolume (audiomanager.adjust_raise, 0);
Decrease Volume:
Copy Code code as follows:
Audio.adjustvolume (audiomanager.adjust_lower, 0);
The above is the most basic method of setting, in the use of many more complex combinations are based on this basic method of combination.