If you still need those that will be called for your activity instance when creating a new instance, you can use this hacker solution . Just do your logic in #doStopOperation () and #doDestroyOperation () instead of #onStop () and #onDestroy () - and be sure to call super # onStop () and super # onDestroy () from your overridden methods. Obviously, when you expand this activity, you donโt need to extend the AppCompatActivity, you can use the usual activity instead. It works for me in production, so hopefully it helps.
I think you could write a hacker timer to call a stop and destroy, even if a new instance is not created, but it is up to you.
milosmns
source share