droft1312
droft1312

Reputation: 473

How to create an instance of a class and override its function in Kotlin?

How would I write the following code in Kotlin?

private final BroadcastReceiver broadcastReceiver = new BroadcastReceiever() {
@Override
public void onReceive(Context context, Intent intent) {

}}

Upvotes: 0

Views: 131

Answers (1)

Konstantin Berkov
Konstantin Berkov

Reputation: 1212

val receiver = object : BroadcastReceiver() {
    override fun onReceive(context: Context, intent: Intent) {...}
}

Upvotes: 1

Related Questions