List of usage examples for android.media AudioManager setStreamSolo
@Deprecated public void setStreamSolo(int streamType, boolean state)
From source file:com.prey.actions.picture.PictureUtil.java
private static byte[] getPicture(Context ctx, String focus) { AudioManager mgr = null; SimpleCameraActivity.dataImagen = null; int streamType = AudioManager.STREAM_SYSTEM; SimpleCameraActivity.activity = null; Intent intent = new Intent(ctx, SimpleCameraActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra("focus", focus); ctx.startActivity(intent);//w w w.jav a 2s .com int i = 0; mgr = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE); mgr.setStreamSolo(streamType, true); mgr.setRingerMode(AudioManager.RINGER_MODE_SILENT); mgr.setStreamMute(streamType, true); while (SimpleCameraActivity.activity == null && i < 10) { try { Thread.sleep(1000); } catch (InterruptedException e) { } i++; } if (SimpleCameraActivity.activity != null) { SimpleCameraActivity.activity.takePicture(ctx, focus); } try { Thread.sleep(4000); } catch (InterruptedException e) { } mgr.setStreamSolo(streamType, false); mgr.setRingerMode(AudioManager.RINGER_MODE_NORMAL); mgr.setStreamMute(streamType, false); try { i = 0; while (SimpleCameraActivity.activity != null && SimpleCameraActivity.dataImagen == null && i < 5) { Thread.sleep(2000); i++; } } catch (InterruptedException e) { PreyLogger.i("Error:" + e.getMessage()); } byte[] out = null; if (SimpleCameraActivity.activity != null) { out = SimpleCameraActivity.dataImagen; SimpleCameraActivity.activity.finish(); SimpleCameraActivity.activity = null; SimpleCameraActivity.dataImagen = null; } return out; }