ultimately you have to track the user interactions. have a look at this post : tracking-user-idle-time-within-the-app-in-android
By using this concept you can track the time and save in preference.
Now remaining logic is only for showing the actionbar if user is not active for some time interval (suppose 2seconds).
For that, You can create a Thread
inside your Activity
which periodically (in your case,at every 2seconds) checks last user-interaction time by calling getElapsed()
method.if getElapsed()
is greater than your desired time(2seconds).then show actionbar using getActionBar().show()
method.