List of usage examples for android.media AudioManager MODE_NORMAL
int MODE_NORMAL
To view the source code for android.media AudioManager MODE_NORMAL.
Click Source Link
From source file:Main.java
public static boolean isOnPause(Context ctx) { AudioManager am = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE); return am.getMode() != AudioManager.MODE_NORMAL; }
From source file:Main.java
public static void openSpeaker(Context context, boolean on) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (on) {//from w w w . j av a2s . com audioManager.setMode(AudioManager.MODE_NORMAL); audioManager.setSpeakerphoneOn(true); } else { audioManager.setSpeakerphoneOn(false); } }
From source file:Main.java
public static void restoreSystemAudioSetting(Context context) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (audioManager != null) { audioManager.setSpeakerphoneOn(false); audioManager.setMode(AudioManager.MODE_NORMAL); }//www . j av a2 s . c o m }
From source file:com.loloof64.android.capturing_audio.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); recordingButton = (ImageButton) findViewById(R.id.button_recording); timerTextView = (TextView) findViewById(R.id.timer_text_view); AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.setMode(AudioManager.MODE_NORMAL); FragmentManager fragmentManager = getSupportFragmentManager(); recorderFragment = (RecorderFragment) fragmentManager.findFragmentByTag(RECORDER_FRAGMENT_TAG); SimpleTimer.setTimerListener(this); if (recorderFragment == null) { recorderFragment = new RecorderFragment(); recorderFragment.setFileRenamingManager(this); recorderFragment.setRecordingStatusListener(this); fragmentManager.beginTransaction().add(recorderFragment, RECORDER_FRAGMENT_TAG).commit(); }/* w ww.ja va 2 s. co m*/ processStatusChange(recorderFragment.isInRecordingStatus()); }
From source file:org.zywx.wbpalmstar.plugin.uexaudio.EUExAudio.java
public static void onActivityDestroy(Context context) { BDebug.i(tag, "onActivityDestroy"); AudioManager audioManager = (AudioManager) context.getApplicationContext() .getSystemService(Context.AUDIO_SERVICE); if (audioManager.getMode() == AudioManager.MODE_IN_COMMUNICATION || audioManager.getMode() == AudioManager.MODE_IN_CALL) { audioManager.setMode(AudioManager.MODE_NORMAL); }/*from w w w . j ava2s. com*/ }
From source file:gstb.fd.eofficial.oa.im.widget.chatrow.EaseChatRowVoicePlayClickListener.java
public void playVoice(String filePath) { Log.e("sssssss", "sssssssssssssss"); if (!(new File(filePath).exists())) { return;/* w w w . j a v a2s .c om*/ } // playMsgId = message.getMsgId(); AudioManager audioManager = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE); mediaPlayer = new MediaPlayer(); // if (EaseUI.getInstance().getSettingsProvider().isSpeakerOpened()) { audioManager.setMode(AudioManager.MODE_NORMAL); audioManager.setSpeakerphoneOn(true); mediaPlayer.setAudioStreamType(AudioManager.STREAM_RING); // } else { // audioManager.setSpeakerphoneOn(false);// // ?Earpiece??? // audioManager.setMode(AudioManager.MODE_IN_CALL); // mediaPlayer.setAudioStreamType(AudioManager.STREAM_VOICE_CALL); // } try { mediaPlayer.setDataSource(filePath); mediaPlayer.prepare(); mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { // TODO Auto-generated method stub mediaPlayer.release(); mediaPlayer = null; stopPlayVoice(); // stop animation } }); isPlaying = true; currentPlayListener = this; mediaPlayer.start(); showAnimation(); // ? if (message.direct() == EMMessage.Direct.RECEIVE) { // if (!message.isAcked() && chatType == EMMessage.ChatType.Chat) { // // ?? //// EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId()); // } if (!message.isListened() && iv_read_status != null && iv_read_status.getVisibility() == View.VISIBLE) { // ???? iv_read_status.setVisibility(View.INVISIBLE); message.setListened(true); MessageDao.instance(activity).updateListen(message.getMsgId()); // EMClient.getInstance().chatManager().setMessageListened(message); } } } catch (Exception e) { System.out.println(); } }
From source file:com.royer.bangstopwatch.app.StopwatchFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Log.d(TAG, "Enter onActivityCreated..."); InitTimeDisplayView();/*w ww .j av a2 s . c om*/ mLapList = (ListView) getView().findViewById(R.id.listLap); this.registerForContextMenu(mLapList); btnStart = (Button) getView().findViewById(R.id.btnStart); btnStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (state == STATE_NONE) { // detect does device support record ? if (AudioRecord.getMinBufferSize(44100, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT) < 0) { Context context = getActivity().getApplicationContext(); Toast toast = Toast.makeText(context, R.string.strNoRecorder, 5); toast.show(); return; } AudioManager audiomanager = (AudioManager) getActivity() .getSystemService(Context.AUDIO_SERVICE); Log.d(TAG, "AudioMode = " + audiomanager.getMode()); if (audiomanager.getMode() != AudioManager.MODE_NORMAL) { Context context = getActivity().getApplicationContext(); Toast toast = Toast.makeText(context, R.string.strInCalling, 5); toast.show(); return; } state = STATE_COUNTDOWN; DialogFragment newFragment = CountdownDialog.NewInstance(5, getTag()); newFragment.show(getFragmentManager(), "countdownDialog"); } else { changeState(); state = STATE_NONE; updateRealElapseTime(); printTime(); // unBind Recordservice if (mBound) { mService.stopRecord(); mService.unsetBang(); getActivity().unbindService(mConnection); getActivity().stopService(new Intent(getActivity(), RecordService.class)); mBound = false; } } ((MainActivity) getActivity()).EnableTab(1, state == STATE_NONE); } }); if (savedInstanceState != null) { Log.d(TAG, "savedInstanceState " + savedInstanceState.toString()); _timekeeper = savedInstanceState.getParcelable(STATE_TIMEKEEPER); mLapManager = savedInstanceState.getParcelable(STATE_LAPS); state = savedInstanceState.getInt(STATE_STATE); mBound = savedInstanceState.getBoolean(STATE_BOUNDING); ((MainActivity) getActivity()).EnableTab(1, state == STATE_NONE); } else { Log.d(TAG, "savedInstanceState == NULL"); if (_timekeeper == null) _timekeeper = new Timekeeper(); if (mLapManager == null) mLapManager = new LapManager(); } InitLapList(); printTime(); updateState(); Log.d(TAG, "Leave OnActivityCreated..."); }
From source file:com.phonegap.AudioHandler.java
/** * Set the audio device to be used for playback. * /* www .jav a 2s. c o m*/ * @param output 1=earpiece, 2=speaker */ public void setAudioOutputDevice(int output) { AudioManager audiMgr = (AudioManager) this.ctx.getSystemService(Context.AUDIO_SERVICE); if (output == 2) { audiMgr.setRouting(AudioManager.MODE_NORMAL, AudioManager.ROUTE_SPEAKER, AudioManager.ROUTE_ALL); } else if (output == 1) { audiMgr.setRouting(AudioManager.MODE_NORMAL, AudioManager.ROUTE_EARPIECE, AudioManager.ROUTE_ALL); } else { System.out.println("AudioHandler.setAudioOutputDevice() Error: Unknown output device."); } }
From source file:com.phonegap.AudioHandler.java
/** * Get the audio device to be used for playback. * /*from w ww . ja v a2 s . co m*/ * @return 1=earpiece, 2=speaker */ public int getAudioOutputDevice() { AudioManager audiMgr = (AudioManager) this.ctx.getSystemService(Context.AUDIO_SERVICE); if (audiMgr.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_EARPIECE) { return 1; } else if (audiMgr.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_SPEAKER) { return 2; } else { return -1; } }
From source file:fr.inria.ucn.collectors.SysStateCollector.java
@SuppressWarnings("deprecation") private JSONObject getAudioState(Context c) throws JSONException { AudioManager am = (AudioManager) c.getSystemService(Context.AUDIO_SERVICE); JSONObject data = new JSONObject(); data.put("is_bluetooth_a2dp_on", am.isBluetoothA2dpOn()); data.put("is_microphone_mute", am.isMicrophoneMute()); data.put("is_music_active", am.isMusicActive()); data.put("is_speaker_phone_on", am.isSpeakerphoneOn()); data.put("is_wired_headset_on", am.isWiredHeadsetOn()); switch (am.getMode()) { case AudioManager.MODE_IN_CALL: data.put("mode", "in_call"); break;//from w w w.ja va 2 s . c o m case AudioManager.MODE_IN_COMMUNICATION: data.put("mode", "in_comm"); break; case AudioManager.MODE_NORMAL: data.put("mode", "normal"); break; case AudioManager.MODE_RINGTONE: data.put("mode", "ringtone"); break; case AudioManager.MODE_INVALID: default: data.put("mode", "invalid"); break; } switch (am.getRingerMode()) { case AudioManager.RINGER_MODE_VIBRATE: data.put("ringer_mode", "vibrate"); break; case AudioManager.RINGER_MODE_SILENT: data.put("ringer_mode", "silent"); break; case AudioManager.RINGER_MODE_NORMAL: data.put("ringer_mode", "normal"); break; default: data.put("ringer_mode", "invalid"); break; } return data; }