Android notification developer getNotification () vs build ()

According to the documentation I saw, the android notification collector was introduced in API 11 and:

  • APIs 11 through 15 use the .getNotification () method to create an object notification
  • API 16 and later use .build () to create a notificaiton object.
It sounds simple enough, but how to write code in Eclipse that will call the correct method depending on the version of the API?
+5
source share
2 answers

If your application supports devices older than API level 11, you should use NotificationCompat.Builder, in which case you can just use build()all the time.

getNotification() , API 16 . . , getNotification() build() .

Raghav, , API.

+14

API Runtime.

if (android.os.Build.VERSION.SDK_INT>=android.os.Build.VERSION_CODES.JELLY_BEAN) {
  // call something for API Level 16+
} else if (android.os.Build.VERSION.SDK_INT>=android.os.Build.VERSION_CODES.HONEYCOMB) {
  // call something for API Level 11+
}
+5

All Articles