我的項目升級到Android的Ø後NotificationCompat.Builder Android中棄用Ø
buildToolsVersion "26.0.1"
皮棉Android Studio中被顯示爲後續通知建設者方法已過時的警告:
new NotificationCompat.Builder(context)
問題是: Android開發人員更新其文檔描述NotificationChannel以支持否tifications在Android的O,併爲我們提供了一個片段,但與同棄用警告:
Notification notification = new Notification.Builder(MainActivity.this)
.setContentTitle("New Message")
.setContentText("You've received new messages.")
.setSmallIcon(R.drawable.ic_notify_status)
.setChannelId(CHANNEL_ID)
.build();
我的問題:有是構建通知任何其他解決方案,而且還支持Android Ø?
我找到的解決方案是將通道ID作爲Notification.Builder構造函數中的參數傳遞。但是這個解決方案並不是完全可重用的。
new Notification.Builder(MainActivity.this, "channel_id")
*但是這個解決方案並不是完全可重用的。 –
NotificationCompat.Builder不推薦使用Notification.Builder。注意Compat部分消失了。通知是他們的新課程,他們正在精簡所有內容 –
@kapsym實際上是另一種方式。 Notification.Builder較老 –