use of android.media.AudioManager in project QRCode by 5peak2me.
the class CaptureActivity method 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;
}
use of android.media.AudioManager in project SeaStar by 13120241790.
the class SettingActivity method onCheckedChanged.
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch(buttonView.getId()) {
case R.id.show_desktopkf:
if (isChecked) {
BroadcastManager.getInstance(mContext).sendBroadcast(START);
edit.putBoolean(DESKTOP, true);
edit.commit();
} else {
BroadcastManager.getInstance(mContext).sendBroadcast(CLOSE);
edit.putBoolean(DESKTOP, false);
edit.commit();
}
break;
case R.id.seting_voice:
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
if (isChecked) {
audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
edit.putBoolean(VOICE, true);
edit.commit();
} else {
audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
edit.putBoolean(VOICE, false);
edit.commit();
}
break;
case R.id.setting_push:
if (isChecked) {
BroadcastManager.getInstance(mContext).sendBroadcast(PUSHSTART);
edit.putBoolean(PUSH, true);
edit.commit();
} else {
BroadcastManager.getInstance(mContext).sendBroadcast(PUSHCLOSE);
edit.putBoolean(PUSH, false);
edit.commit();
}
break;
}
}
use of android.media.AudioManager in project android_frameworks_base by DirtyUnicorns.
the class VideoView method stopPlayback.
public void stopPlayback() {
if (mMediaPlayer != null) {
mMediaPlayer.stop();
mMediaPlayer.release();
mMediaPlayer = null;
mCurrentState = STATE_IDLE;
mTargetState = STATE_IDLE;
AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
am.abandonAudioFocus(null);
}
}
use of android.media.AudioManager in project android_frameworks_base by DirtyUnicorns.
the class VideoView method release.
/*
* release the media player in any state
*/
private void release(boolean cleartargetstate) {
if (mMediaPlayer != null) {
mMediaPlayer.reset();
mMediaPlayer.release();
mMediaPlayer = null;
mPendingSubtitleTracks.clear();
mCurrentState = STATE_IDLE;
if (cleartargetstate) {
mTargetState = STATE_IDLE;
}
AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
am.abandonAudioFocus(null);
}
}
use of android.media.AudioManager in project android_frameworks_base by DirtyUnicorns.
the class BluetoothTestUtils method startStopSco.
/**
* Helper method for {@link #startSco(BluetoothAdapter, BluetoothDevice)} and
* {@link #stopSco(BluetoothAdapter, BluetoothDevice)}.
*
* @param adapter The BT adapter.
* @param device The remote device.
* @param isStart Whether the SCO channel should be opened.
*/
private void startStopSco(BluetoothAdapter adapter, BluetoothDevice device, boolean isStart) {
long start = -1;
int mask;
String methodName;
if (isStart) {
methodName = String.format("startSco(device=%s)", device);
mask = StartStopScoReceiver.STATE_CONNECTED_FLAG;
} else {
methodName = String.format("stopSco(device=%s)", device);
mask = StartStopScoReceiver.STATE_DISCONNECTED_FLAG;
}
if (!adapter.isEnabled()) {
fail(String.format("%s bluetooth not enabled", methodName));
}
if (!adapter.getBondedDevices().contains(device)) {
fail(String.format("%s device not paired", methodName));
}
AudioManager manager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
assertNotNull(manager);
if (!manager.isBluetoothScoAvailableOffCall()) {
fail(String.format("%s device does not support SCO", methodName));
}
boolean isScoOn = manager.isBluetoothScoOn();
if (isStart == isScoOn) {
return;
}
StartStopScoReceiver receiver = getStartStopScoReceiver(mask);
start = System.currentTimeMillis();
if (isStart) {
manager.startBluetoothSco();
} else {
manager.stopBluetoothSco();
}
long s = System.currentTimeMillis();
while (System.currentTimeMillis() - s < START_STOP_SCO_TIMEOUT) {
isScoOn = manager.isBluetoothScoOn();
if (isStart == isScoOn && (receiver.getFiredFlags() & mask) == mask) {
long finish = receiver.getCompletedTime();
if (start != -1 && finish != -1) {
writeOutput(String.format("%s completed in %d ms", methodName, (finish - start)));
} else {
writeOutput(String.format("%s completed", methodName));
}
removeReceiver(receiver);
return;
}
sleep(POLL_TIME);
}
int firedFlags = receiver.getFiredFlags();
removeReceiver(receiver);
fail(String.format("%s timeout: on=%b (expected %b), flags=0x%x (expected 0x%x)", methodName, isScoOn, isStart, firedFlags, mask));
}
Aggregations