Android Notification.Builder vs NotificationCompat.Builder [duplicate]

谁说我不能喝 提交于 2019-12-07 16:12:11

问题


Pretty much all the bits of sample code I see for Android notififactions appear to use NotificationCompat. I have written up my own code using Notification.Builder. It is not clear to me what benefits, if any, there might be in using NotificationCompat.Builder. I hope that someone here might be able to explain the differences.


回答1:


You can use things like NotificationCompat.Builder#setLargeIcon(Bitmap) to allow you to take full advantage of Android 3.0+ with things like the large icon, while maintaining compatibility on versions of Android prior to 3.0 that do not support such things.




回答2:


depends on what you are trying to do and what OS version's your app is compatible with but in most cases you would want to use NotificationCompat because that provides backwards compatibility where as if you wanted to provide that with the regular Notification.Builder you would have to check what OS version the device has yourself to use API calls that are not in older versions



来源:https://stackoverflow.com/questions/39749482/android-notification-builder-vs-notificationcompat-builder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!