October 2018
Intermediate to advanced
464 pages
15h 17m
English
The first detail to notice is how we construct the object itself. As we mentioned in the introduction, the SoundPool constructor was changed in Lollipop (API 21). The old constructor was deprecated in favor of using SoundPool.Builder(). With a constantly changing environment such as Android, changes in the API are very common, so it's a good idea to learn how to work with the changes. As you can see, it's not difficult in this case. We just check the current OS version and call the appropriate method. It is worth noting the two method annotations. The first specifies the target API:
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
And the second suppresses the deprecation warning:
@SuppressWarnings("deprecation")
After creating ...