hay im new in kotlin and i try to push notification in my app. Unfortunately I'm having this error: "getSystemServise unresolved reference" this is my code:
val intent = Intent()
val pendingIntent = PendingIntent.getActivity(this.activity,0,intent,0)
val notification = Notification.Builder(this.activity)
.setContentTitle("time is:")
.setContentText("text")
.setSmallIcon(R.drawable.notification_icon_background)
.setContentIntent(pendingIntent)
val nm:NotificationManager = getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(0,notification.build())
thanks for helpers
Please make sure that you add the id 'kotlin-android-extensions' line on the build. gradle file that's inside your app module. Once you sync the Gradle build, the error should disappear.
I was also facing the same issue.
I got the partial solution with the previous answers, but there is one more thing that you have to mention, i.e. that the variable is nullable or not and put the operators accordingly:
val downloadManager = context?.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With