Android profile settings

Source: Internet
Author: User

Profile settings Everyone should be quite familiar with it, but how to set up the situation mode in Android through their own program, the situation mode is divided into many kinds, that is, you can use the system comes with, or you can use the custom, but in the development of some programs, you may need to change the profile in the program, Then this will require the setting of the scenario mode. Here's a brief description of how the situation mode is set up:
First get the current story mode:
Code

Copy CodeThe code is 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 the initial mode
}


This code, of course, need to be processed again, then you can get the current situation mode, for future settings to prepare, and then may also know whether to set again.
Setting the profile one: only sound, no vibrations:
Code

Copy CodeThe code is 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, "Setup succeeded! Current for ringtones ", Toast.length_long). Show ();
}


After setting the system only sound, no vibration.
Set the profile two: there are sounds and vibrations:
Code

Copy CodeThe code is 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, "Setup succeeded! Currently for ringtones plus vibrate ", Toast.length_long). Show ();
}


When this is set, there will also be a vibration alert when the sound is audible.
Setting the profile three: only vibrations:
Code

Copy CodeThe code is 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, "Setup succeeded! Current for vibration ", Toast.length_long). Show ();
}


After this setting only vibrate, no sound:
Set profile four: Silent Vibration Free:
Code

Copy CodeThe code is 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, "Setup succeeded! Current is silent no vibration ", Toast.length_long). Show ();
}


The system does not have sound and vibration after setting. The appropriate prompt cannot be made.
The sound of all the above settings is the system default sound size, then whether we can customize the size of the sound, the answer is of course yes. To set the size of the sound, you need to set the following function:
To increase the volume:

Copy CodeThe code is as follows:
Audio.adjustvolume (audiomanager.adjust_raise, 0);


To decrease the volume:

Copy CodeThe code is as follows:
Audio.adjustvolume (audiomanager.adjust_lower, 0);


The above is the most basic method of Setup, in the use of many more complex combinations are the basic method of combination.

Android profile settings

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.