This is a follow up question to this question:
Force application to restart on first activity
I am trying to restart my application from a fragment like that:
As the accepted answer doesn't seem to work on Android Q anymore due to the new background launch limitations, let me add my own solution:
startActivity(
Intent(applicationContext, MainActivity::class.java)
)
System.exit(0)
Although it looks strange, it works very reliably for me, as the intent takes longer to fire than the system exit does. Plus, it is fired from the main thread, so Android Q won't complain.