Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8774591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:36:26+00:00 2026-06-13T18:36:26+00:00

I have an application where you have to log in like an user with

  • 0

I have an application where you have to log in like an user with your password.

This application needs to be secure, so it needs to Log Out the user when he doesn´t tocuh the screen during a determinate period of time(let´s say, 5 minutes).

The problem is that, once the user is logged in, he can go through many activities, not only one, and I would like to know if there is a way in Android to know if the user can get Logged out after few minutes.

I was thinking about using the method onInterceptTouchEvent(MotionEvent ev), but the problem is that, ¿do I have to use this method on every activities? ¿there is another easier way to manage it in Android?

Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:36:27+00:00Added an answer on June 13, 2026 at 6:36 pm

    Instead of implementing this on every Activity, you could create one Activity like this:

    public class BaseActivity extends Activity
    

    and implement onInterceptTouchEvent in your BaseActivity.

    Then from all other Activities you will have to extend the BaseActivity

    UPDATE:
    You will have to use onTouch if you want to listen for events in whole screen. This requires that in every xml file of your Activity, you will have to give an id for the root view of your xml (Linearlayout, Relativelayout, Framelayout or whatever). So in order to let your BaseActivity get inputs from other Activities you will have to pass your root view to it, like this:

    public class MyActivity extends BaseActivity{
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.my_activity);
            super.setRootView(findViewById(R.id.rootView));
        }
    }
    
    public class BaseActivity extends Activity implements OnTouchListener{
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
        }
    
        public void setRootView(View rootView){
            rootView.setOnTouchListener(this);
        }
    
        public boolean onTouch(View v, MotionEvent event) {
            Log.d("BaseActivity", "onTouch!");
            return super.onTouchEvent(event);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have multiple log files like database log, weblog, quartzlog in our application. Any
I have an odd exception in our application and I'd like to log when
I have a log.txt file on the root of my application. I would like
I have an android application and web-server working together. Now I want user log
I have an application that uses OAuth whose logic is something like this: If
I'd like to add several different user types to my rails application. I have
I have an asp.net c# web application where a user can log in and
I see an application have used Log.info = some info where are these logs
I have a Samsung Galaxy Y. My application writes log file to sd card
I have a java application that people can log into (and do various things

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.