本文整理汇总了Java中android.media.AudioManager.RINGER_MODE_NORMAL属性的典型用法代码示例。如果您正苦于以下问题:Java AudioManager.RINGER_MODE_NORMAL属性的具体用法?Java AudioManager.RINGER_MODE_NORMAL怎么用?Java AudioManager.RINGER_MODE_NORMAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.media.AudioManager
的用法示例。
在下文中一共展示了AudioManager.RINGER_MODE_NORMAL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldBeep
private static boolean shouldBeep(SharedPreferences prefs, Context activity) {
boolean shouldPlayBeep = true;
if (shouldPlayBeep) {
// See if sound settings overrides this
AudioManager audioService = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
shouldPlayBeep = false;
}
}
return shouldPlayBeep;
}
示例2: startMusic
public void startMusic(int type, int startTime) {
/* Check if Music is allowed to start */
requestFocus();
if(noFocus)
return;
if(isInactive)
return;
if(isMusicReady) {
/* NOP */
} else {
loadMusic(type,startTime);
}
if(isMusicReady) {
if(audioCEO.getRingerMode() != AudioManager.RINGER_MODE_NORMAL)
return;
musicPlayer.setVolume(0.01f * PreferenceManager.getDefaultSharedPreferences(host).getInt("pref_musicvolume", 60), 0.01f * PreferenceManager.getDefaultSharedPreferences(host).getInt("pref_musicvolume", 60));
musicPlayer.start();
}
}
示例3: buttonSound
public void buttonSound() {
if(noFocus)
return;
if(audioCEO.getRingerMode() != AudioManager.RINGER_MODE_NORMAL)
return;
if(!PreferenceManager.getDefaultSharedPreferences(host).getBoolean("pref_button_sound", true))
return;
soundPool.play(
soundID_buttonSoundPlayer,
0.01f * PreferenceManager.getDefaultSharedPreferences(host).getInt("pref_soundvolume", 60),
0.01f * PreferenceManager.getDefaultSharedPreferences(host).getInt("pref_soundvolume", 60),
1,
0,
1.0f
);
}
示例4: onResume
@Override
protected void onResume() {
super.onResume();
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
SurfaceHolder surfaceHolder = surfaceView.getHolder();
if (hasSurface) {
initCamera(surfaceHolder);
} else {
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
decodeFormats = null;
characterSet = null;
playBeep = true;
AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
playBeep = false;
}
initBeepSound();
vibrate = true;
}
示例5: StartCameraScanner
public void StartCameraScanner() {
inactivityTimer = new InactivityTimer(this.getActivity());
if (!hasSurface) {
initCamera(surfaceHolder);
} else {
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
decodeFormats = null;
characterSet = null;
playBeep = true;
AudioManager audioService = (AudioManager) getActivity().getSystemService(getActivity().AUDIO_SERVICE);
if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
playBeep = false;
}
initBeepSound();
vibrate = true;
}
示例6: onResume
@Override
protected void onResume() {
super.onResume();
SurfaceHolder surfaceHolder = surfaceView.getHolder();
if (hasSurface) {
initCamera(surfaceHolder);
} else {
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
decodeFormats = null;
characterSet = null;
playBeep = true;
AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
playBeep = false;
}
initBeepSound();
vibrate = true;
}
示例7: shouldBeep
private static boolean shouldBeep(SharedPreferences prefs, Context activity) {
boolean shouldPlayBeep = prefs.getBoolean(PreferencesActivity.KEY_PLAY_BEEP, true);
if (shouldPlayBeep) {
// See if sound settings overrides this
AudioManager audioService = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
shouldPlayBeep = false;
}
}
return shouldPlayBeep;
}
示例8: shouldBeep
private static boolean shouldBeep(SharedPreferences prefs, Context activity) {
boolean shouldPlayBeep = true;
if (shouldPlayBeep) {
// See if sound settings overrides this
AudioManager audioService = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
shouldPlayBeep = false;
}
}
return shouldPlayBeep;
}
示例9: shouldBeep
private static boolean shouldBeep(SharedPreferences prefs, Context activity) {
boolean shouldPlayBeep = prefs.getBoolean(activity.getString(R.string.preferences_play_beep), true);
if (shouldPlayBeep) {
// See if sound settings overrides this
AudioManager audioService = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
shouldPlayBeep = false;
}
}
return shouldPlayBeep;
}
示例10: start
public void start() {
AudioManager audioManager = ServiceUtil.getAudioManager(context);
if (player != null) player.release();
player = createPlayer();
int ringerMode = audioManager.getRingerMode();
if (shouldVibrate(context, player, ringerMode)) {
Log.i(TAG, "Starting vibration");
vibrator.vibrate(VIBRATE_PATTERN, 1);
}
if (player != null && ringerMode == AudioManager.RINGER_MODE_NORMAL) {
try {
if (!player.isPlaying()) {
player.prepare();
player.start();
Log.w(TAG, "Playing ringtone now...");
} else {
Log.w(TAG, "Ringtone is already playing, declining to restart.");
}
} catch (IllegalStateException | IOException e) {
Log.w(TAG, e);
player = null;
}
} else {
Log.w(TAG, "Not ringing, mode: " + ringerMode);
}
}
示例11: shouldBeep
private static boolean shouldBeep(SharedPreferences prefs, Context activity) {
boolean shouldPlayBeep = true;//prefs.getBoolean(PreferencesActivity.KEY_PLAY_BEEP, true);
if (shouldPlayBeep) {
// See if sound settings overrides this
AudioManager audioService = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
shouldPlayBeep = false;
}
}
return shouldPlayBeep;
}
示例12: playAudio
/**
* 播放音效
*
* @param pSoundName
*/
public void playAudio(String pSoundName)
{
if (mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL)
{
// 在响铃模式为Normal的情况下播放音频
// 音频对应id,左右声道大小,优先级,循环次数,播放速率:1代表正常播放:范围:0.5-2
mSoundPool.play(mSoundPoolMap.get(pSoundName).intValue(), 1, 1, 0, 0, 1);
}
}
示例13: shouldBeep
private static boolean shouldBeep(SharedPreferences prefs, Context activity) {
boolean shouldPlayBeep = prefs.getBoolean(PreferencesActivity.KEY_PLAY_BEEP, true);
if (shouldPlayBeep) {
// See if sound settings overrides this
AudioManager audioService = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
shouldPlayBeep = false;
}
}
return shouldPlayBeep;
}
示例14: onItemClick
public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) {
AudioManager manager = (AudioManager) mActivity.getSystemService(Context.AUDIO_SERVICE);
if (manager != null) {
int ringerMode = AudioManager.RINGER_MODE_NORMAL;
int vibroMode = AudioManager.VIBRATE_SETTING_ON;
switch(index) {
case 0: // silent
ringerMode = AudioManager.RINGER_MODE_SILENT;
vibroMode = AudioManager.VIBRATE_SETTING_ONLY_SILENT;
break;
case 1: // vibro
ringerMode = AudioManager.RINGER_MODE_VIBRATE;
vibroMode = AudioManager.VIBRATE_SETTING_ON;
break;
case 2: // sound
ringerMode = AudioManager.RINGER_MODE_NORMAL;
vibroMode = AudioManager.VIBRATE_SETTING_OFF;
break;
case 3: // sound and vibro
ringerMode = AudioManager.RINGER_MODE_NORMAL;
vibroMode = AudioManager.VIBRATE_SETTING_ON;
break;
}
// update manager modes
// update
manager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, vibroMode);
manager.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, vibroMode);
manager.setRingerMode(ringerMode);
validateState(manager);
}
mDialog.hide();
}
示例15: playRingtone
public void playRingtone() {
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
// Honour silent mode
switch (audioManager.getRingerMode()) {
case AudioManager.RINGER_MODE_NORMAL:
mPlayer = new MediaPlayer();
mPlayer.setAudioStreamType(AudioManager.STREAM_RING);
try {
if(hasSIM())
mPlayer.setDataSource(mContext, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE));
else
mPlayer.setDataSource(mContext, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM));
mPlayer.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "Could not setup media player for ringtone");
mPlayer = null;
return;
}
mPlayer.setLooping(true);
mPlayer.start();
break;
case AudioManager.RINGER_MODE_VIBRATE:
mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
if(mVibrator.hasVibrator()) {
long[] pattern = {0, 500, 200};
// The '0' here means to repeat indefinitely
// '0' is actually the index at which the pattern keeps repeating from (the start)
// To repeat the pattern from any other point, you could increase the index, e.g. '1'
mVibrator.vibrate(pattern, 0);
}
break;
}
}