List of usage examples for android.content Context AUDIO_SERVICE
String AUDIO_SERVICE
To view the source code for android.content Context AUDIO_SERVICE.
Click Source Link
From source file:Main.java
/** * Utility method that returns and AudioManager for the Activity passed in * @param activity the Activity that will be associated to the AudioManager * @return the AudioManager object for the passed Activity *//*from www . j a v a2s.c om*/ public static AudioManager setAudioManager(Activity activity) { return (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE); }
From source file:Main.java
private static AudioManager getInstance(Context context) { synchronized (lock) { if (audioManager != null) return audioManager; if (context != null) audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); return audioManager; }/*from www . j a v a 2 s.co m*/ }
From source file:Main.java
private static AudioManager getInstance(Context context) { synchronized (mSingletonLock) { if (audioManager != null) return audioManager; if (context != null) audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); return audioManager; }/* www. j a v a2 s .c o m*/ }
From source file:Main.java
public static void silentAlarm(Context context) { if (player != null) { Log.i("AlarmHelper", "silented"); try {/* w w w. jav a 2 s . c o m*/ if (player.isLooping()) { player.setLooping(false); } player.pause(); player.stop(); player.release(); } catch (IllegalStateException e) { AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); am.setStreamVolume(AudioManager.STREAM_ALARM, 0, 0); } // player.setVolume(0, 0); AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); am.setStreamVolume(AudioManager.STREAM_ALARM, mUserVolume, 0); } else { Log.i("AlarmHelper", "ring zero"); AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); am.setStreamVolume(AudioManager.STREAM_ALARM, 0, 0); } if (vibrator != null) { vibrator.cancel(); } else { vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vibrator.cancel(); } }
From source file:Main.java
public static void setRinger2Normal(Context context) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); //setting the volume audioManager.setStreamVolume(AudioManager.STREAM_RING, currentVolume, 0); Log.i("HelperFunctions ", "Normal method called"); }
From source file:Main.java
/** * Play an alarm sound on the device/*from w w w . j a va 2 s.c o m*/ * * @param context The context * @return MediaPlayer */ public static MediaPlayer playAlarmSound(Context context) { MediaPlayer mediaPlayer = new MediaPlayer(); try { mediaPlayer.setDataSource(context, getAlarmUri()); final AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (audioManager.getStreamVolume(AudioManager.STREAM_ALARM) != 0) { mediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM); mediaPlayer.prepare(); mediaPlayer.start(); } return mediaPlayer; } catch (IOException e) { return null; } }
From source file:Main.java
public static void setRinger2Vibrate(Context context) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE); Log.i("HelperFunctions ", "Vibrate method called"); }
From source file:Main.java
public static void setRinger2Silent(Context context) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT); Log.i("HelperFunctions ", "Silent method called"); }
From source file:com.metinkale.prayerapp.vakit.AlarmReceiver.java
public static void silenter(Context c, long dur) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c); boolean silent = "silent".equals(prefs.getString("silenterType", "silent")); AudioManager aum = (AudioManager) c.getSystemService(Context.AUDIO_SERVICE); int ringermode = aum.getRingerMode(); if ((ringermode != AudioManager.RINGER_MODE_SILENT) && ((ringermode != AudioManager.RINGER_MODE_VIBRATE) || silent)) { AlarmManager am = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE); Intent i;/* www .j a v a 2 s . com*/ if (ringermode == AudioManager.RINGER_MODE_VIBRATE) { i = new Intent(c, setVibrate.class); } else { i = new Intent(c, setNormal.class); } PendingIntent service = PendingIntent.getBroadcast(c, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (1000 * 60 * dur), service); if (PermissionUtils.get(c).pNotPolicy) aum.setRingerMode(silent ? AudioManager.RINGER_MODE_SILENT : AudioManager.RINGER_MODE_VIBRATE); } }
From source file:org.chromium.tools.audio_focus_grabber.AudioFocusGrabberListenerService.java
@Override public void onCreate() { super.onCreate(); mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE); }