android.media.AudioManager#STREAM_NOTIFICATION源码实例Demo

下面列出了android.media.AudioManager#STREAM_NOTIFICATION 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: webrtc_android   文件: WebRtcAudioUtils.java
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";
  }
}
 
源代码2 项目: webrtc_android   文件: WebRtcAudioUtils.java
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";
  }
}
 
@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();
    }
}
 
源代码4 项目: Noyze   文件: OppoVolumePanel.java
@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 };
    }
}
 
源代码5 项目: NoiseCapture   文件: CalibrationService.java
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;
    }
}
 
源代码6 项目: Noyze   文件: StatusBarPlusVolumePanel.java
@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;
        }
    }
}
 
源代码7 项目: Noyze   文件: ParanoidVolumePanel.java
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;
}
 
源代码8 项目: android_emulator_hacks   文件: Badservice.java
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);
}
 
源代码9 项目: financisto   文件: NotificationOptions.java
private void applySound(Notification notification) {
	if (sound == null) {
		notification.sound = null;
	} else {
		notification.audioStreamType = AudioManager.STREAM_NOTIFICATION;
		notification.sound = Uri.parse(sound);
	}
}
 
@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();
}
 
源代码11 项目: Yahala-Messenger   文件: MessagesController.java
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);
        }

    }
 
@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);
}
 
源代码13 项目: Noyze   文件: AudioHelper.java
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;
}
 
源代码14 项目: RedEnvelopeAssistant   文件: SoundHelper.java
public SoundHelper(Context context){
       mSoundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
       soundIdRedEnvelopeComing = mSoundPool.load(context, R.raw.red_envelope_coming, 1);
}
 
源代码15 项目: android_9.0.0_r45   文件: MediaSessionService.java
private boolean isValidLocalStreamType(int streamType) {
    return streamType >= AudioManager.STREAM_VOICE_CALL
            && streamType <= AudioManager.STREAM_NOTIFICATION;
}
 
源代码16 项目: android_9.0.0_r45   文件: SeekBarVolumizer.java
private static boolean isNotificationOrRing(int stream) {
    return stream == AudioManager.STREAM_RING || stream == AudioManager.STREAM_NOTIFICATION;
}
 
@Override
public void onCreate() {
    toneGenerator = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
}
 
源代码18 项目: RobotCA   文件: HUDFragment.java
/**
 * Default Constructor.
 */
public HUDFragment() {
    toneGenerator = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
}
 
源代码19 项目: Study_Android_Demo   文件: DatabaseHelper.java
/**
 * 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);
}
 
源代码20 项目: Study_Android_Demo   文件: DatabaseHelper.java
/**
 * 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);
}