Piotr Prus
03/10/2022, 10:25 AMactionStartActivity
. The click parameter is assign during composition and I cannot use hte dynamic state as I can for ActionCallback. Rephrasing:
Is there a way to start activity but using class ActionCallback
? This class is called on click, not during composition, so i can get my parameters base on glanceID. @Marcel Pinto?daivid
03/10/2022, 2:43 PMclass MyWidgetAction : ActionCallback {
override suspend fun onRun(context: Context, glanceId: GlanceId, parameters: ActionParameters) {
Intent(context, MyActivity::class.java).apply {
// put your extras in this intent, then just start it context.startActivity(this)
}
}
}
☝️ with something like thatPiotr Prus
03/10/2022, 4:06 PMdaivid
03/10/2022, 5:51 PMprivate fun startSomeNiceActivity(theExtra: Long, context: Context) = actionStartActivity(
Intent(context, MyActivity::class).apply {
putExtra("the_extra_key", theExtra)
}
)
Piotr Prus
03/10/2022, 7:09 PMMarcel Pinto
03/14/2022, 9:01 AMPiotr Prus
03/14/2022, 5:23 PMGlanceModifier
.fillMaxSize()
.clickable(onClick = actionStartActivity(intent = Intent().also { Log.d("This is called on composition, no when user click") })
Option 2: actionCallback
GlanceModifier
.fillMaxSize()
.clickable(onClick = actionRunCallback<MyAction>())
MyAction class:
class MyAction : ActionCallback {
override suspend fun onRun(context: Context, glanceId: GlanceId, parameters: ActionParameters) {
Log.d("This is called only after click")
}
Marcel Pinto
07/01/2022, 12:37 PM