Java Code Examples for android.media.AudioManager#STREAM_NOTIFICATION

The following examples show how to use android.media.AudioManager#STREAM_NOTIFICATION . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebRtcAudioUtils.java    From webrtc_android with MIT License 6 votes vote down vote up
private static String streamTypeToString(int stream) {
  switch(stream) {
    case AudioManager.STREAM_VOICE_CALL:
      return "STREAM_VOICE_CALL";
    case AudioManager.STREAM_MUSIC:
      return "STREAM_MUSIC";
    case AudioManager.STREAM_RING:
      return "STREAM_RING";
    case AudioManager.STREAM_ALARM:
      return "STREAM_ALARM";
    case AudioManager.STREAM_NOTIFICATION:
      return "STREAM_NOTIFICATION";
    case AudioManager.STREAM_SYSTEM:
      return "STREAM_SYSTEM";
    default:
      return "STREAM_INVALID";
  }
}
 
Example 2
Source File: WebRtcAudioUtils.java    From webrtc_android with MIT License 6 votes vote down vote up
private static String streamTypeToString(int stream) {
  switch (stream) {
    case AudioManager.STREAM_VOICE_CALL:
      return "STREAM_VOICE_CALL";
    case AudioManager.STREAM_MUSIC:
      return "STREAM_MUSIC";
    case AudioManager.STREAM_RING:
      return "STREAM_RING";
    case AudioManager.STREAM_ALARM:
      return "STREAM_ALARM";
    case AudioManager.STREAM_NOTIFICATION:
      return "STREAM_NOTIFICATION";
    case AudioManager.STREAM_SYSTEM:
      return "STREAM_SYSTEM";
    default:
      return "STREAM_INVALID";
  }
}
 
Example 3
Source File: StatusBarPlusVolumePanel.java    From Noyze with Apache License 2.0 6 votes vote down vote up
@Override
public void onRingerModeChange(int ringerMode) {
    super.onRingerModeChange(ringerMode);
    if (null != mLastVolumeChange) {
        switch (mLastVolumeChange.mStreamType) {
            case AudioManager.STREAM_NOTIFICATION:
            case AudioManager.STREAM_RING:
                switch (ringerMode) {
                    case RINGER_MODE_VIBRATE:
                        icon.setImageResource(getVibrateIcon());
                        break;
                    case RINGER_MODE_SILENT:
                    default:
                        icon.setImageResource(getSilentIcon());
                        break;
                }
                break;
        }
    }
}
 
Example 4
Source File: MqttSettingsCodeReaderFragment.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 6 votes vote down vote up
@Override
public void onCodeScanned(String contents) {
    Log.d(TAG, "Code Scanned: " + contents);
    if (isCodeAlreadyScanned) {
        return;
    }       // To avoid double scans and pop 2 times the fragment
    isCodeAlreadyScanned = true;

    // Beep
    final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
    tg.startTone(ToneGenerator.TONE_PROP_BEEP);

    //
    mListener.onPasswordUpdated(contents);

    // Pop current fragment
    FragmentActivity activity = getActivity();
    if (activity != null) {
        FragmentManager fragmentManager = activity.getSupportFragmentManager();
        fragmentManager.popBackStack();
    }
}
 
Example 5
Source File: CalibrationService.java    From NoiseCapture with GNU General Public License v3.0 6 votes vote down vote up
private int getAudioOutput() {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    String value = sharedPref.getString("settings_calibration_audio_output", "STREAM_MUSIC");

    if("STREAM_VOICE_CALL".equals(value)) {
        return AudioManager.STREAM_VOICE_CALL;
    } else if("STREAM_SYSTEM".equals(value)) {
        return AudioManager.STREAM_SYSTEM;
    } else if("STREAM_RING".equals(value)) {
        return AudioManager.STREAM_RING;
    } else if("STREAM_MUSIC".equals(value)) {
        return AudioManager.STREAM_MUSIC;
    } else if("STREAM_ALARM".equals(value)) {
        return AudioManager.STREAM_ALARM;
    } else if("STREAM_NOTIFICATION".equals(value)) {
        return AudioManager.STREAM_NOTIFICATION;
    } else if("STREAM_DTMF".equals(value)) {
        return AudioManager.STREAM_DTMF;
    } else {
        return AudioManager.STREAM_RING;
    }
}
 
Example 6
Source File: OppoVolumePanel.java    From Noyze with Apache License 2.0 6 votes vote down vote up
@Override protected int[] getStreamIcons(StreamControl sc) {
    if (sc.streamType == STREAM_BLUETOOTH_SCO)
        return new int[] { R.drawable.oppo_ic_audio_bt, R.drawable.oppo_ic_audio_bt_mute };
    switch (sc.streamType) {
        case AudioManager.STREAM_ALARM:
            return new int[] { R.drawable.oppo_ic_audio_alarm, R.drawable.oppo_ic_audio_alarm_mute };
        case AudioManager.STREAM_RING:
            return new int[] { R.drawable.oppo_ic_audio_ring_notif, R.drawable.oppo_ic_audio_ring_notif_mute };
        case AudioManager.STREAM_NOTIFICATION:
            return new int[] { R.drawable.oppo_ic_audio_notification, R.drawable.oppo_ic_audio_notification_mute };
        case AudioManager.STREAM_MUSIC:
            return new int[] { R.drawable.oppo_ic_audio_media, R.drawable.oppo_ic_audio_media_mute };
        case AudioManager.STREAM_VOICE_CALL:
            return new int[] { R.drawable.oppo_ic_audio_phone, R.drawable.oppo_ic_audio_phone };
        default:
            return new int[] { R.drawable.oppo_ic_audio_vol, R.drawable.oppo_ic_audio_vol_mute };
    }
}
 
Example 7
Source File: AudioHelper.java    From Noyze with Apache License 2.0 5 votes vote down vote up
boolean updateRingerModeAffectedStreams(Context context) {
    int ringerModeAffectedStreams;

    // make sure settings for ringer mode are consistent with device type: non voice capable
    // devices (tablets) include media stream in silent mode whereas phones don't.
    ringerModeAffectedStreams = Settings.System.getInt(context.getContentResolver(),
            Settings.System.MODE_RINGER_STREAMS_AFFECTED,
            ((1 << AudioManager.STREAM_RING)|(1 << AudioManager.STREAM_NOTIFICATION)|
             (1 << AudioManager.STREAM_SYSTEM)));

    // ringtone, notification and system streams are always affected by ringer mode
    ringerModeAffectedStreams |= (1 << AudioManager.STREAM_RING)|
            (1 << AudioManager.STREAM_NOTIFICATION)|
            (1 << AudioManager.STREAM_SYSTEM);

    if (mVoiceCapable) {
        ringerModeAffectedStreams &= ~(1 << AudioManager.STREAM_MUSIC);
    } else {
        ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC);
    }

    if (ringerModeAffectedStreams != mRingerModeAffectedStreams) {
        mRingerModeAffectedStreams = ringerModeAffectedStreams;
        return true;
    }
    return false;
}
 
Example 8
Source File: ParanoidVolumePanel.java    From Noyze with Apache License 2.0 5 votes vote down vote up
protected int[] _getStreamIcons(StreamControl sc) {
    int[] icons = getStreamIcons(sc);
    if (sc.streamType == AudioManager.STREAM_NOTIFICATION ||
            sc.streamType == AudioManager.STREAM_RING) {
        switch (mRingerMode) {
            case AudioManager.RINGER_MODE_VIBRATE:
                icons[1] = getVibrateIcon();
                break;
            case AudioManager.RINGER_MODE_SILENT:
                icons[1] = getSilentIcon();
                break;
        }
    }
    return icons;
}
 
Example 9
Source File: BackgroundLocationUpdateService.java    From cordova-background-geolocation-services with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Log.i(TAG, "OnCreate");

    toneGenerator           = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
    notificationManager     = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
    connectivityManager     = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);

    // Location Update PI
    Intent locationUpdateIntent = new Intent(Constants.LOCATION_UPDATE);
    locationUpdatePI = PendingIntent.getBroadcast(this, 9001, locationUpdateIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    registerReceiver(locationUpdateReceiver, new IntentFilter(Constants.LOCATION_UPDATE));

    Intent detectedActivitiesIntent = new Intent(Constants.DETECTED_ACTIVITY_UPDATE);
    detectedActivitiesPI = PendingIntent.getBroadcast(this, 9002, detectedActivitiesIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    registerReceiver(detectedActivitiesReceiver, new IntentFilter(Constants.DETECTED_ACTIVITY_UPDATE));

    // Receivers for start/stop recording
    registerReceiver(startRecordingReceiver, new IntentFilter(Constants.START_RECORDING));
    registerReceiver(stopRecordingReceiver, new IntentFilter(Constants.STOP_RECORDING));
    registerReceiver(startAggressiveReceiver, new IntentFilter(Constants.CHANGE_AGGRESSIVE));

    // Location criteria
    criteria = new Criteria();
    criteria.setAltitudeRequired(false);
    criteria.setBearingRequired(false);
    criteria.setSpeedRequired(true);
    criteria.setCostAllowed(true);
}
 
Example 10
Source File: MessagesController.java    From Yahala-Messenger with MIT License 5 votes vote down vote up
public MessagesController() {

        MessagesStorage storage = MessagesStorage.getInstance();
        SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
        preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
        fontSize = preferences.getInt("fons_size", 16);

        try {
            soundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
            sound = soundPool.load(ApplicationLoader.applicationContext, R.raw.electronic, 1);
        } catch (Exception e) {
            FileLog.e("yahala", e);
        }

    }
 
Example 11
Source File: MqttUartSettingsCodeReaderActivity.java    From Bluefruit_LE_Connect_Android with MIT License 5 votes vote down vote up
@Override
public void onCodeScanned(String contents) {
    Log.d(TAG, "Code Scanned: " + contents);

    // Beep
    final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
    tg.startTone(ToneGenerator.TONE_PROP_BEEP);

    //
    Intent data = new Intent();
    data.putExtra(kActivityResult_ScannedContents, contents);
    setResult(RESULT_OK, data);
    finish();
}
 
Example 12
Source File: NotificationOptions.java    From financisto with GNU General Public License v2.0 5 votes vote down vote up
private void applySound(Notification notification) {
	if (sound == null) {
		notification.sound = null;
	} else {
		notification.audioStreamType = AudioManager.STREAM_NOTIFICATION;
		notification.sound = Uri.parse(sound);
	}
}
 
Example 13
Source File: Badservice.java    From android_emulator_hacks with Apache License 2.0 5 votes vote down vote up
private void muteVolume() {
    int[] volumes = new int[]{AudioManager.STREAM_VOICE_CALL, AudioManager.STREAM_SYSTEM, AudioManager.STREAM_RING, AudioManager.STREAM_MUSIC, AudioManager.STREAM_NOTIFICATION};
    for (int volumeType : volumes) {
        audio.setStreamMute(volumeType, true);
    }
    audio.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_OFF);
    audio.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF);
}
 
Example 14
Source File: AbstractLocationProvider.java    From background-geolocation-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate() {
    toneGenerator = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
}
 
Example 15
Source File: HUDFragment.java    From RobotCA with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Default Constructor.
 */
public HUDFragment() {
    toneGenerator = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
}
 
Example 16
Source File: SeekBarVolumizer.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private static boolean isNotificationOrRing(int stream) {
    return stream == AudioManager.STREAM_RING || stream == AudioManager.STREAM_NOTIFICATION;
}
 
Example 17
Source File: DatabaseHelper.java    From Study_Android_Demo with Apache License 2.0 4 votes vote down vote up
/**
 * Loads the default volume levels. It is actually inserting the index of
 * the volume array for each of the volume controls.
 *
 * @param db the database to insert the volume levels into
 */
private void loadVolumeLevels(SQLiteDatabase db) {
    SQLiteStatement stmt = null;
    try {
        stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
                + " VALUES(?,?);");

        loadSetting(stmt, Settings.System.VOLUME_MUSIC,
                AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_MUSIC]);
        loadSetting(stmt, Settings.System.VOLUME_RING,
                AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_RING]);
        loadSetting(stmt, Settings.System.VOLUME_SYSTEM,
                AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_SYSTEM]);
        loadSetting(
                stmt,
                Settings.System.VOLUME_VOICE,
                AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_VOICE_CALL]);
        loadSetting(stmt, Settings.System.VOLUME_ALARM,
                AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_ALARM]);
        loadSetting(
                stmt,
                Settings.System.VOLUME_NOTIFICATION,
                AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_NOTIFICATION]);
        loadSetting(
                stmt,
                Settings.System.VOLUME_BLUETOOTH_SCO,
                AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_BLUETOOTH_SCO]);

        // By default:
        // - ringtones, notification, system and music streams are affected by ringer mode
        // on non voice capable devices (tablets)
        // - ringtones, notification and system streams are affected by ringer mode
        // on voice capable devices (phones)
        int ringerModeAffectedStreams = (1 << AudioManager.STREAM_RING) |
                                        (1 << AudioManager.STREAM_NOTIFICATION) |
                                        (1 << AudioManager.STREAM_SYSTEM) |
                                        (1 << AudioManager.STREAM_SYSTEM_ENFORCED);
        if (!mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_voice_capable)) {
            ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC);
        }
        loadSetting(stmt, Settings.System.MODE_RINGER_STREAMS_AFFECTED,
                ringerModeAffectedStreams);

        loadSetting(stmt, Settings.System.MUTE_STREAMS_AFFECTED,
                ((1 << AudioManager.STREAM_MUSIC) |
                 (1 << AudioManager.STREAM_RING) |
                 (1 << AudioManager.STREAM_NOTIFICATION) |
                 (1 << AudioManager.STREAM_SYSTEM)));
    } finally {
        if (stmt != null) stmt.close();
    }

    loadVibrateWhenRingingSetting(db);
}
 
Example 18
Source File: DatabaseHelper.java    From Study_Android_Demo with Apache License 2.0 4 votes vote down vote up
/**
 * Loads the default volume levels. It is actually inserting the index of
 * the volume array for each of the volume controls.
 *
 * @param db the database to insert the volume levels into
 */
private void loadVolumeLevels(SQLiteDatabase db) {
    SQLiteStatement stmt = null;
    try {
        stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
                + " VALUES(?,?);");

        loadSetting(stmt, Settings.System.VOLUME_MUSIC,
                AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_MUSIC));
        loadSetting(stmt, Settings.System.VOLUME_RING,
                AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_RING));
        loadSetting(stmt, Settings.System.VOLUME_SYSTEM,
                AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_SYSTEM));
        loadSetting(
                stmt,
                Settings.System.VOLUME_VOICE,
                AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_VOICE_CALL));
        loadSetting(stmt, Settings.System.VOLUME_ALARM,
                AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_ALARM));
        loadSetting(
                stmt,
                Settings.System.VOLUME_NOTIFICATION,
                AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_NOTIFICATION));
        loadSetting(
                stmt,
                Settings.System.VOLUME_BLUETOOTH_SCO,
                AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_BLUETOOTH_SCO));

        // By default:
        // - ringtones, notification, system and music streams are affected by ringer mode
        // on non voice capable devices (tablets)
        // - ringtones, notification and system streams are affected by ringer mode
        // on voice capable devices (phones)
        int ringerModeAffectedStreams = (1 << AudioManager.STREAM_RING) |
                                        (1 << AudioManager.STREAM_NOTIFICATION) |
                                        (1 << AudioManager.STREAM_SYSTEM) |
                                        (1 << AudioManager.STREAM_SYSTEM_ENFORCED);
        if (!mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_voice_capable)) {
            ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC);
        }
        loadSetting(stmt, Settings.System.MODE_RINGER_STREAMS_AFFECTED,
                ringerModeAffectedStreams);

        loadSetting(stmt, Settings.System.MUTE_STREAMS_AFFECTED,
                AudioSystem.DEFAULT_MUTE_STREAMS_AFFECTED);
    } finally {
        if (stmt != null) stmt.close();
    }

    loadVibrateWhenRingingSetting(db);
}
 
Example 19
Source File: MediaSessionService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private boolean isValidLocalStreamType(int streamType) {
    return streamType >= AudioManager.STREAM_VOICE_CALL
            && streamType <= AudioManager.STREAM_NOTIFICATION;
}
 
Example 20
Source File: SoundHelper.java    From RedEnvelopeAssistant with MIT License 4 votes vote down vote up
public SoundHelper(Context context){
       mSoundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
       soundIdRedEnvelopeComing = mSoundPool.load(context, R.raw.red_envelope_coming, 1);
}