List of usage examples for android.media AudioManager STREAM_NOTIFICATION
int STREAM_NOTIFICATION
To view the source code for android.media AudioManager STREAM_NOTIFICATION.
Click Source Link
From source file:de.j4velin.chess.Main.java
@Override public void onTurnBasedMatchReceived(final TurnBasedMatch match) { if (BuildConfig.DEBUG) Logger.log("Main onTurnBasedMatchReceived: " + match.getMatchId()); if (match.getTurnStatus() == TurnBasedMatch.MATCH_TURN_STATUS_MY_TURN && match.getStatus() == TurnBasedMatch.MATCH_STATUS_ACTIVE) { final Ringtone tone = RingtoneManager.getRingtone(this, RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_NOTIFICATION)); tone.setStreamType(AudioManager.STREAM_NOTIFICATION); tone.play();//w w w . j a v a 2 s . c o m } if (startFragment != null && startFragment.isVisible()) { startFragment.loadMatches(); } if (gameFragment != null && gameFragment.isVisible() && match.getMatchId().equals(gameFragment.currentMatch)) { if (Game.load(match.getData(), match, mGoogleApiClient)) { gameFragment.update(match.getStatus() != TurnBasedMatch.MATCH_STATUS_ACTIVE && match.getStatus() != TurnBasedMatch.MATCH_STATUS_AUTO_MATCHING); } else { updateApp(); } } }
From source file:org.wso2.iot.agent.AlertActivity.java
/** * This method is used to start ringing the phone. *///w w w . j a v a 2 s . c o m @TargetApi(21) private void startRing() { if (audio != null) { ringerMode = audio.getRingerMode(); ringerVolume = audio.getStreamVolume(AudioManager.STREAM_RING); audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL); audio.setStreamVolume(AudioManager.STREAM_RING, audio.getStreamMaxVolume(AudioManager.STREAM_RING), AudioManager.FLAG_PLAY_SOUND); defaultRingtoneUri = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_RINGTONE); if (defaultRingtoneUri != null) { defaultRingtone = RingtoneManager.getRingtone(this, defaultRingtoneUri); if (defaultRingtone != null) { if (deviceInfo.getSdkVersion() >= Build.VERSION_CODES.LOLLIPOP) { AudioAttributes attributes = new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_NOTIFICATION) .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).build(); defaultRingtone.setAudioAttributes(attributes); } else { defaultRingtone.setStreamType(AudioManager.STREAM_NOTIFICATION); } defaultRingtone.play(); } } } }
From source file:org.wso2.emm.agent.AlertActivity.java
/** * This method is used to start ringing the phone. *///w w w.j a va 2 s . com @TargetApi(21) private void startRing() { if (audio != null) { audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL); audio.setStreamVolume(AudioManager.STREAM_RING, audio.getStreamMaxVolume(AudioManager.STREAM_RING), AudioManager.FLAG_PLAY_SOUND); defaultRingtoneUri = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_RINGTONE); if (defaultRingtoneUri != null) { defaultRingtone = RingtoneManager.getRingtone(this, defaultRingtoneUri); if (defaultRingtone != null) { if (deviceInfo.getSdkVersion() >= Build.VERSION_CODES.LOLLIPOP) { AudioAttributes attributes = new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_NOTIFICATION) .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).build(); defaultRingtone.setAudioAttributes(attributes); } else { defaultRingtone.setStreamType(AudioManager.STREAM_NOTIFICATION); } defaultRingtone.play(); } } } }
From source file:com.securecomcode.text.notifications.MessageNotifier.java
private static void sendInThreadNotification(Context context) { try {/*from ww w. j a va 2 s . co m*/ if (!TextSecurePreferences.isInThreadNotifications(context)) { return; } String ringtone = TextSecurePreferences.getNotificationRingtone(context); if (ringtone == null) return; Uri uri = Uri.parse(ringtone); MediaPlayer player = new MediaPlayer(); player.setAudioStreamType(AudioManager.STREAM_NOTIFICATION); player.setDataSource(context, uri); player.setLooping(false); player.setVolume(0.25f, 0.25f); player.prepare(); final AudioManager audioManager = ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)); audioManager.requestAudioFocus(null, AudioManager.STREAM_NOTIFICATION, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK); player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { audioManager.abandonAudioFocus(null); } }); player.start(); } catch (IOException ioe) { Log.w("MessageNotifier", ioe); } }
From source file:net.inbox.Pager.java
private void activity_load() { // Init notification sound beep = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 1000); // Init vibrations vvv = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); Toolbar tb = (Toolbar) findViewById(R.id.home_toolbar); setSupportActionBar(tb);/*from w w w . j av a 2 s . c o m*/ tf = Typeface.createFromAsset(getAssets(), "fonts/Dottz.ttf"); // Find the title TextView tv_t; for (int i = 0; i < tb.getChildCount(); ++i) { int idd = tb.getChildAt(i).getId(); if (idd == -1) { tv_t = (TextView) tb.getChildAt(i); tv_t.setTextColor(ContextCompat.getColor(this, R.color.color_title)); tv_t.setTypeface(tf); break; } } if (getSupportActionBar() != null) { getSupportActionBar().setTitle(getString(R.string.activity_pager_title).toUpperCase()); } // Unread Messages Counter tv_page_counter = (TextView) findViewById(R.id.page_counter); tv_page_counter.setTypeface(tf); // Mass Refresh Button ImageButton iv_refresh = (ImageButton) findViewById(R.id.refresh); iv_refresh.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mass_refresh_check(); } }); // No accounts message is visible if the user has not init-ed the app tv_no_account = (TextView) findViewById(R.id.no_accounts); tv_no_account.setTypeface(tf); // Filling the ListView of the home window inbox_list_view = (ListView) findViewById(R.id.accounts_list_view); populate_list_view(); }
From source file:com.squalala.talkiewalkie.ui.activities.TalkActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_talk); ButterKnife.bind(this); connectedUserFragment = new ConnectedUserFragment(); settingsFragment = new SettingsFragment(); messageAdapter = new MessageAdapter(messages, new OnClickMessageListener() { @Override// www . j ava 2 s . c om public void onClickMessage(Message message) { message.setRead(false); recyclerView.getAdapter().notifyDataSetChanged(); mMessages.add(message); playAudios(); } }); linearLayoutManager = new LinearLayoutManager(this); linearLayoutManager.setStackFromEnd(true); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setAdapter(messageAdapter); progressView.setVisibility(View.VISIBLE); btnUserOnline.setVisibility(View.GONE); txtWhatHappen.setVisibility(View.GONE); // txtNumberUsers.setVisibility(View.GONE); txtWhoSpeak.setVisibility(View.GONE); session = ((App) getApplication()).getSession(); mSocket = ((App) getApplication()).getSocket(); mSocket.on(Socket.EVENT_CONNECT, onConnect); mSocket.on(Socket.EVENT_DISCONNECT, onDisconnect); mSocket.on(Socket.EVENT_CONNECT_ERROR, onConnectError); mSocket.on(Socket.EVENT_CONNECT_TIMEOUT, onConnectError); mSocket.on(KEY_NEW_MESSAGE, onNewMessage); mSocket.on(KEY_JOIN_ROOM, onJoinRoom); mSocket.on(KEY_LEFT_ROOM, onLeftRoom); mSocket.on(KEY_NUMBER_USERS, onNumberUsers); mSocket.on(KEY_CONNECTED_USERS, onConnectedUsers); mSocket.connect(); /* if (session.isBeep()) iconBeep.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_volume_up_black_48dp)); else iconBeep.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_volume_off_black_48dp)); */ amanager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE); // int maxVolume = amanager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); // System.out.println("Max volume " + maxVolume); // System.out.println("session Max volume " + session.getSoundVolume()); amanager.setStreamVolume(AudioManager.STREAM_MUSIC, session.getSoundVolume(amanager), 0); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayerForBeep.setAudioStreamType(AudioManager.STREAM_NOTIFICATION); mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @DebugLog @Override public void onCompletion(MediaPlayer mediaPlayer) { viewAvatar.setVisibility(View.GONE); // pulsator.stop(); if (session.isAutomaticPlay()) playAudios(); } }); mIvVoiceIndicators = new ArrayList<>(); mIvVoiceIndicators.add(ButterKnife.<ImageView>findById(this, R.id.mIvVoiceIndicator1)); mIvVoiceIndicators.add(ButterKnife.<ImageView>findById(this, R.id.mIvVoiceIndicator2)); mIvVoiceIndicators.add(ButterKnife.<ImageView>findById(this, R.id.mIvVoiceIndicator3)); mIvVoiceIndicators.add(ButterKnife.<ImageView>findById(this, R.id.mIvVoiceIndicator4)); mIvVoiceIndicators.add(ButterKnife.<ImageView>findById(this, R.id.mIvVoiceIndicator5)); mIvVoiceIndicators.add(ButterKnife.<ImageView>findById(this, R.id.mIvVoiceIndicator6)); mIvVoiceIndicators.add(ButterKnife.<ImageView>findById(this, R.id.mIvVoiceIndicator7)); mAudioRecorder = AudioRecorder.getInstance(); mRxAudioPlayer = RxAudioPlayer.getInstance(); mAudioRecorder.setOnErrorListener(this); btnSpeak.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: press2Record(); break; case MotionEvent.ACTION_UP: release2Send(); break; case MotionEvent.ACTION_CANCEL: release2Send(); break; default: break; } return true; } }); }
From source file:org.telegram.messenger.MessagesController.java
public MessagesController() { MessagesStorage storage = MessagesStorage.Instance; NotificationCenter.Instance.addObserver(this, FileLoader.FileDidUpload); NotificationCenter.Instance.addObserver(this, FileLoader.FileDidFailUpload); NotificationCenter.Instance.addObserver(this, 10); addSupportUser();//from w w w.j a v a 2s.com SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); enableJoined = preferences.getBoolean("EnableContactJoined", true); try { soundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0); sound = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_a, 1); } catch (Exception e) { FileLog.e("tmessages", e); } }
From source file:cl.gisred.android.RepartoActivity.java
private void alertFail() { ToneGenerator tgFail = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); tgFail.startTone(ToneGenerator.TONE_CDMA_SOFT_ERROR_LITE, 200); Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(1000);//from w ww. java2 s . c o m }
From source file:com.concentriclivers.mms.com.android.mms.transaction.MessagingNotification.java
/** * Play the in-conversation notification sound (it's the regular notification sound, but * played at half-volume/*from w w w . ja v a2 s . com*/ */ private static void playInConversationNotificationSound(Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); String ringtoneStr = sp.getString(MessagingPreferenceActivity.NOTIFICATION_RINGTONE, null); if (TextUtils.isEmpty(ringtoneStr)) { // Nothing to play return; } Uri ringtoneUri = Uri.parse(ringtoneStr); NotificationPlayer player = new NotificationPlayer(LogTag.APP); player.play(context, ringtoneUri, false, AudioManager.STREAM_NOTIFICATION, IN_CONVERSATION_NOTIFICATION_VOLUME); }
From source file:org.thoughtcrime.SMP.notifications.MessageNotifier.java
private static void sendInThreadNotification(Context context, Recipients recipients) { try {//from w w w . j av a 2 s . com if (!TextSecurePreferences.isInThreadNotifications(context)) { return; } Uri uri = recipients.getRingtone(); if (uri == null) { String ringtone = TextSecurePreferences.getNotificationRingtone(context); if (ringtone == null) { Log.w(TAG, "ringtone preference was null."); return; } else { uri = Uri.parse(ringtone); } } if (uri == null) { Log.w(TAG, "couldn't parse ringtone uri " + TextSecurePreferences.getNotificationRingtone(context)); return; } MediaPlayer player = new MediaPlayer(); player.setAudioStreamType(AudioManager.STREAM_NOTIFICATION); player.setDataSource(context, uri); player.setLooping(false); player.setVolume(0.25f, 0.25f); player.prepare(); final AudioManager audioManager = ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)); audioManager.requestAudioFocus(null, AudioManager.STREAM_NOTIFICATION, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK); player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { audioManager.abandonAudioFocus(null); } }); player.start(); } catch (IOException ioe) { Log.w("MessageNotifier", ioe); } }