Tag Archives: java.lang.IllegalStateException: Fragment already added

Kotlin Viewpager+fragment error: java.lang.IllegalStateException: Fragment already added

private var fileUrl: String = "" 
private var taskIds: String = ""
override fun onActivityCreated(savedInstanceState: Bundle?) { 
    super.onActivityCreated(savedInstanceState) 
    fileUrl = activity!!.intent.getStringExtra("fileUrl") 
    taskIds = activity!!.intent.getStringExtra("taskIds") 
} 
If this is used then if If getStringExtra() returns null, it will report java.lang.IllegalStateException: Fragment already added