0

enter image description here

Recently I converted the Java code into the Kotlin like pushnotification. After the conversion its shown some error and indicate to manually correct those issues.

In Java:

.addFlags(notifyDetails.flags |= Notification.FLAG_AUTO_CANCEL); 

After the conversion it's shown like

.addFlags(notifyDetails!!.flags notifyDetails!!.flags or Notification.FLAG_AUTO_CANCEL)

Also, it's indicating an error. How do I fix this?

2

1 Answer 1

3

Kotlin doesn't allow you to use assignments such as |= as part of an expression. You need to split this into two expressions:

notifyDetailsFlags = notifyDetailsFlags or Notification.FLAG_AUTO_CANCEL

// the beginning of the call
.addFlags(notifyDetailsFlags)
Sign up to request clarification or add additional context in comments.

3 Comments

Still i am getting error only...private var notifyDetails: Notification? = null; notifyDetails = notifyDetails or Notification.FLAG_AUTO_CANCEL inapp_btn.addFlags(notifyDetails)
Please show a larger snippet of your code. You need to fix the nullability, but I can't show you how to do this correctly based on this single line.
Screen added above

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.