6572kk后台播放音乐,进入情景模式预览铃声音量时,后台音乐不停止播放,要求预览铃声时关闭后台播放的音乐,使用AudioFocus机制

6572kk后台播放音乐,进入情景模式预览铃声音量时,后台音乐不停止播放,要求预览铃声时关闭后台播放的音乐,使用AudioFocus机制

72kk\packages\apps\Settings\src\com\mediatek\audioprofile\RingerVolumePreference.java

 @Override
    protected void onBindDialogView(View view) {
        super.onBindDialogView(view);

        Context context = getContext();
        mReceiver = new VolumeReceiver();
        IntentFilter filter = new IntentFilter();
        filter.addAction(AudioManager.VOLUME_CHANGED_ACTION);
        context.registerReceiver(mReceiver, filter);

        mIsDlgDismissed = false;
        Xlog.d(TAG, "set mIsDlgDismissed to false ");
		
		//zxw add start
		mAudioManager.requestAudioFocus(null, 		      AudioManager.STREAM_RING,AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
		//zxw add end
		...
	}

@Override
    protected void onDialogClosed(boolean positiveResult) {
        super.onDialogClosed(positiveResult);
		mAudioManager.abandonAudioFocus(null);
        if (mSeekBarVolumizer == null) {
            return;
        }
        ...
    }

你可能感兴趣的:(java)