You should be familiar with setting the scene mode, but how to use your ownProgramYou can set the scenario mode in multiple ways, that is, you can use the built-in or custom scenarios, but when developing some programs, you may need to change the context mode in the program. The following describes how to set the situation mode:
First, obtain the current scene mode:
Code
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 icons respectively
Int Mode = Audio. getringermode (); // Get initial Mode
}
Use thisCodeOf course, you need to process it again so that you can get the current scene mode, prepare for future settings, and you may know whether to set it again.
Set scene mode 1: sound, no vibration:
Code
VoidRing (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 successfully! Currently, it is a ringtone.", Toast. length_long). Show ();
}
After setting, the system only has sound and no vibration.
Set scene mode 2: either sound or vibration:
Code
VoidRingandvibrate (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 successfully! Currently, the ringtone and vibration are added.", Toast. length_long). Show ();
}
After this setting, there will also be a vibration reminder when the voice is voiced.
Set scene mode 3: Vibration only:
Code
VoidVibrate (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 successfully! Current as Vibration", Toast. length_long). Show ();
}
After this setting, There is only vibration and no sound:
Set scene mode 4: silent and non-vibration:
Code
VoidNoringandvibrate (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 successfully! Currently it is silent and non-Vibration", Toast. length_long). Show ();
}
After the settings, the system does not have sound or vibration. The error message is not displayed.
The voice of all the above settings is the default sound size of the system. Can we customize the sound size? The answer is yes of course. To set the sound size, you need to set the following function:
Increase volume:
Audio. adjustvolume (audiomanager. adjust_raise,0);
Decrease volume:
Audio. adjustvolume (audiomanager. adjust_lower,0);
The above is the most basic setting method. Many of the more complex combinations in use are formed by the combination of the basic methods.