October 2018
Intermediate to advanced
464 pages
15h 17m
English
The first detail to note is that we decorate our showNotification() method with the following:
@SuppressWarnings("deprecated")
This tells the compiler we know we are using deprecated calls. (Without this, the compiler will flag the code.) We follow this with an API check, using this call:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
The icon resource was changed in API 23, but we want this application to run on API 21 (Android 5.0) and later, so we still need to call the old methods when running on API 21 and API 22.
If the user is running on Android 6.0 (or higher), we use the new Icon class to create our icons; otherwise, we use the old constructor. (You'll notice the IDE shows deprecated calls with a strikethrough.) ...