Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin - getPendingIntent with multiple flags syntax [duplicate]

Tags:

android

kotlin

I'm trying to notify simple notification as in Java code

what is the syntax for this line in kotlin?

stackBuilder.getPendingIntent(0, PendingIntent.FLAG_ONE_SHOT | Intent.FLAG_ACTIVITY_NEW_TASK);

in kotlin, I can't use '|' for 2 flags, only like this:

stackBuilder.getPendingIntent(0,PendingIntent.FLAG_ONE_SHOT)
like image 889
itzhar Avatar asked Dec 24 '22 16:12

itzhar


1 Answers

You can find the available bitwise operations in the official docs here. These are all infix functions that are spelled out in Kotlin instead of using special symbols.

In your case, you can do the following:

stackBuilder.getPendingIntent(0, PendingIntent.FLAG_ONE_SHOT or Intent.FLAG_ACTIVITY_NEW_TASK);
like image 115
zsmb13 Avatar answered Dec 28 '22 08:12

zsmb13