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 8070665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:27:37+00:00 2026-06-05T13:27:37+00:00

When a user clicks, case MotionEvent.ACTION_DOWN is triggered. When the click is released, case

  • 0

When a user clicks, case MotionEvent.ACTION_DOWN is triggered. When the click is released, case MotionEvent.ACTION_UP is triggered.

I’m interested in determining if ACTION_UP hasn’t been triggered within 3 seconds of ACTION_DOWN. Meaning, If 3 seconds have passed since the user has clicked and has not yet released, I want to know, essentially trying to determine a long click.

Is there a way to do such a thing?

   switch (event.getAction()) {
       case MotionEvent.ACTION_DOWN:
       break;
       case MotionEvent.ACTION_UP:
       break;
    }
  • 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-05T13:27:39+00:00Added an answer on June 5, 2026 at 1:27 pm

    Generally the right way to detect a long-click is by implementing
    View.OnLongClickListener. This is easier and less error-prone that detecting it yourself, and it ensures that your app fits in well with the rest of the system.

    For a custom View, you would add implements View.OnLongClickListener to your class declaration, add setOnLongClickListener(this); to the constructor, and add the onLongClick() method to your class:

    public boolean onLongClick (View v) {
        // Handle long-click
    }
    

    If your View isn’t custom you can add the listener like this:

    theView.setLongClickable(true);
    theView.setOnLongClickListener(new View.OnLongClickListener() {
        public boolean onLongClick(View v) {
            // Handle long-click
        }
    });
    

    Update: Okay, I’ve done some digging, and while this is the right way to do it for every View I’ve ever worked with, it in fact does not work for SeekBars, which is what the questioner is working with. This fact is not documented in the SeekBar documentation, but experimentation has shown it to be true, and digging through the source code shows why: SeekBar.onTouchEvent() does not call super.onTouchEvent(). It is in View.onTouchEvent() that performLongClick() is called, if appropriate.

    The way I would implement it if I had to is with Handler.postDelayed(). On ACTION_DOWN, I would post (with e.g. 3000ms delay) a Runnable that handles the long-press to a Handler, and I’d cancel it on ACTION_UP. So any press for less than the delay doesn’t end up calling the Runnable, but if ACTION_UP hasn’t occurred after the delay, it is.

    That said, I’d caution you to rethink doing this at all. What does it mean to long-press a SeekBar? If the user is dragging the “thumb” for longer than the delay, suddenly you have a long-press that probably was not meant as one. You can cancel and reset the delay every time the thumb is moved, requiring a long-press to be several seconds in exactly one position. But it’s rare to be perfectly still; it’s in fact difficult to hold the thumb yet not move it for several seconds. So you could then have a minimum change in thumb position that resets the delay. That’s what I would do if I had to, but I must say it’s a very strange user experience.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Use case: user clicks the link on a webpage - boom! load of files
Here's the use case: A user clicks on a link that opens a window
I am using WPFToolKit DataGrid to display data; In my use case user clicks
I'm interested in having my LIs toggle when a user clicks in the blank
I am handling cell content click event. When user clicks the content of a
I need to handle the case when a user clicks on a mapTypeControl differently
Use case: User clicks a link, a modal window is displayed containing one big
I'm making a click counter, i.e, when a user clicks a button, we want
When user clicks on select box , I want to hide the options menu
When a user clicks a submit button I want the form to be submitted.

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.