• 播放系统默认提示音


        static MediaPlayer mMediaPlayer;
        public static void play() {
            try {
                Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                mMediaPlayer = new MediaPlayer();
                mMediaPlayer.setDataSource(Registry.context2, alert);
                final AudioManager audioManager = (AudioManager) Registry.context2.getSystemService(Context.AUDIO_SERVICE);
                if (audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION) != 0) {
                    mMediaPlayer.setAudioStreamType(AudioManager.STREAM_NOTIFICATION);
                    mMediaPlayer.setLooping(false);
                    mMediaPlayer.prepare();
                    mMediaPlayer.start();
                    mMediaPlayer.setOnCompletionListener(new OnCompletionListener() {                    
                        @Override
                        public void onCompletion(MediaPlayer mp) {
                            mp.release();
                        }
                    });
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

  • 相关阅读:
    supervisor集群管理
    ansible安装es集群
    ansible安装应用实例
    ansible任务控制
    ansible的playbook基础
    ansiblie命令基础
    iptables命令详解
    ansible基础理论
    shell动态修改yml配置文件
    JAVA8 Stream()遍历求某列总和
  • 原文地址:https://www.cnblogs.com/highfly2012/p/3056180.html
Copyright © 2020-2023  润新知