2

I have registered launcher before activity get started but some times when launch is called on listener it gets crashed and reason is mentioned below

Sometimes I am getting this:

java.lang.IllegalStateException: Attempting to launch an unregistered ActivityResultLauncher with contract j.c@ab78423 and input Intent You must ensure the ActivityResultLauncher is registered before calling launch().

any solution?

I am following below approach :

  1. Creating launcher variable for activityResultLauncher before activity is created

private var launcher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> // handling result }

  1. And launching this after activity is created by using below method: launcher.launch()
vikas jain
  • 31
  • 3

0 Answers0