1

I am trying to implement a glance widget and start an activity while clicking on a button. But it seems like it's not working properly for me. This is my code:

 DistributionDateView(context, deliveryDates, postalCode) {
                println("it should work i think")
                actionStartActivity(AddParcelManuallyActivity.newIntent(context = context))
                actionStartActivity<AddParcelManuallyActivity>()
                actionStartActivity(AddParcelManuallyActivity::class.java)
}

Where DistributionDateView has a onclick. I have tried 3 different ways, "it should work I think" is printing in the logs... but nothing is happening. What am I doing wrong here.

Meyben
  • 451
  • 3
  • 15

1 Answers1

1

Same Issue here (using androidx.glance:glance-appwidget:1.0.0-beta01). My Workaround is starting Activity the usual way:

            Intent(context, MyActivity::class.java).apply{
            flags = FLAG_ACTIVITY_NEW_TASK
            context.startActivity(this)
        }

Important is the use of "FLAG_ACTIVITY_NEW_TASK" cause you are calling startActivity() from outside of an Activity

walex
  • 36
  • 1
  • 1