<lambda>null1 package com.android.sharetest
2 
3 import android.app.PendingIntent
4 import android.content.Context
5 import android.content.Intent
6 import android.graphics.drawable.Icon
7 import android.service.chooser.ChooserAction
8 
9 class CustomActionFactory(private val context: Context) {
10     fun getCustomActions(count: Int): Array<ChooserAction> {
11         val actions = Array(count) { idx ->
12             val customAction = PendingIntent.getBroadcast(
13                 context,
14                 idx,
15                 Intent(BROADCAST_ACTION),
16                 PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_CANCEL_CURRENT
17             )
18             ChooserAction.Builder(
19                 Icon.createWithResource(context, R.drawable.testicon),
20                 "Action ${idx + 1}",
21                 customAction
22             ).build()
23         }
24 
25         return actions
26     }
27 
28     companion object {
29         const val BROADCAST_ACTION = "broadcast-action"
30     }
31 }
32