-
안드로이드 버전에 상관없이 재생되는 코드
SoundPool mSp = null; int mAlertid = 0; public void sndinit() { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { AudioAttributes attributes = new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_GAME) .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) .build(); mSp = new SoundPool.Builder() .setAudioAttributes(attributes) .build(); //ot mSp = new SoundPool.Builder().setMaxStreams(3).build(); } else { mSp = new SoundPool(3, AudioManager.STREAM_NOTIFICATION, 0); } mAlertid = mSp.load(this, R.raw.alert, 1); } public void sndplay() { mSp.play(mAlertid, 1, 1, 1, 0, 1); }
'Android' 카테고리의 다른 글
Android App 이름 (1) 2021.03.09 Android logcat Log 종류 (0) 2021.03.08 Android adb logcat 명령어 (0) 2021.03.08 안드로이드 알림 로그 (Notification History Log) (0) 2021.01.11 Google - Maps SDK for Android 정보 (0) 2020.07.26 Android - Realm (ORM, Database) (0) 2020.07.26 Android - BroadcastReceiver (0) 2020.07.20 Android - Google Map 적용 (0) 2020.07.19