-
Notifications
You must be signed in to change notification settings - Fork 0
Description
the issue is reproductible in the following scenario:
Let's say we have two Activities A and B.
The user wants initialize the Capture ONLY on demand, in this case for example we add a button that handle Capture.init in the activity A (till now everything OK).
note = until now in the CaptureActivityLifecycleCallbacks, the activityCount = 0
Now we navigate from the activity A to Activity B
- onActivityStarted (
B) will be called(activityCount== 0 =>FOREGROUND;activityCount ++=> activityCount =1 =>Captureconnect ) - onActivityStopped (
A) will be called after (activityCount --=>activityCount= 0 ;BACKGROUND=>CaptureDisconnect)
As we see here, once we are in B activity, the state of Capture is Disconnected !
class ActivityA : AppCompatActivity() {
.....
override fun onCreate(savedInstanceState: Bundle?) {
.....
binding.initSocket.setOnClickListener {
Capture.builder(getApplicationContext())
.enableLogging(BuildConfig.DEBUG)
.build()
Capture.connect{}
}
binding.goToB.setOnClickListener {
//till now every thing works fine
startActivity(Intent(this, ActivityB::class.java))
}
}
}
class ActivityB : AppCompatActivity() {
.....
//my Capture is not connected any more , even if we go back to ActivityA
}
As solution for this issue, i think it will be better to add in CaptureActivityLifecycleCallbacks class a List of started activities , and we change visibility to gone only the already started activities... In resume we stop only started activities.
Or add some method to increment activityCount manually