Oreo 에뮬레이터에서 간단한 알림을 표시하려고했습니다. 이상하게도 나는 아무것도 볼 수 없다.Oreo 에뮬레이터에 알림이 표시되지 않습니다.
명백한 답을 없애자. 앱에 대한 알림을 확인하려고했지만 Notifications 및 NotificationCompat 경로를 사용해 보았습니다. 나는 채널을 유무에 관계없이 시도했다. 나는 그룹과 함께 또는 그룹없이 시도했다.
코드 (예, 코 틀린를 사용하지만 그것을 이해하기 쉽게) 초등학교입니다 :
class MainActivity : Activity() {
var id = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val button:View = findViewById(R.id.button)
button.setOnClickListener(this::onAddNotification)
}
private fun onAddNotification(v: View) {
id++
val builder = Notification.Builder(this).setSmallIcon(R.drawable.ic_notifications_none)
.setContentTitle("Content #$id").setContentText("Content text for $id")
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.notify(id, builder.build())
}
}
없이는 사전 오레오에 완벽하게 작동 코드의 말을. 반면 Gmail 및지도는 해당 에뮬레이터에 대한 알림을 표시합니다. 내가 잊어 버렸던 것은 무엇입니까? 당신이 한 4로 (NotificationCompat 제대로 그것을 처리하지 않는 것을 염두에 수로
베어를 사용해야합니다 당신이 API26를 사용하는 경우
감사
당신 *** 필수 *** 사용 채널 –
음, 올바른. 그것 또는 "API 26 아직 사용하지 마십시오". NotificationCompat는 아직 지원하지 않습니다. Uncool, Google, uncool! –