I have a simple app to count the number of repetitions of different exercises.
What I would like to do is to move to a new window (Activity in my case) when the set number of repetitions is reached. To do that, I call a new activity in onSensorChanged like:
override fun onSensorChanged(event: SensorEvent?) {
if(repetitionTracker.getNumberOfRepetitions() <= maxRepetitions ){
intent_next = Intent(this, End::class.java)
intent_next.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(intent_next)
}
}
But the application crash when reaching this point
I tried everything that was suggested here: Start Activity from Service in Android.
But I couldn't find a way to make it work. I suppose that the problem is to use Android 10+
Do you know what is the right pattern/method to do this kind of operations? I'm also open to not call a new activity but something else if this is the correct way of doing it