User auto log off with Firebase nd timming

Hi there! A little help>
I am doing and auto log off on an app using Firebase authentication, right now I use a Handler and a runnable to count down my desired time and a onUserInteraction to monitor app, and after this proceed to do the FirebaseAuth.getInstance().signOut()
But I do need to copy the code for each activity and this seems not efficient.

Any Ideas on this?