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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:49:37+00:00 2026-05-22T01:49:37+00:00

I have developed an Android application that is handling multitouch in a view. I

  • 0

I have developed an Android application that is handling multitouch in a view. I basically track the several MotionEvents that can occur like ACTION_UP, ACTION_MOVE, … My overwritten onTouch method in the View class looks like this:

public boolean onTouch(View view, MotionEvent event) 
{
    int action = event.getAction() & MotionEvent.ACTION_MASK;

    if (action == MotionEvent.ACTION_DOWN) {
        float x = event.getX();
        handleTouchStart(view, x);
    } else if (action == MotionEvent.ACTION_UP) {
        float x = event.getX();
        handleTouchEnded(view, x);
    } else if (action == MotionEvent.ACTION_POINTER_DOWN) {
        int pointer = (event.getAction() & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
        float x = event.getX(pointer);
        handleTouchStart(view, x);
    } else if (action == MotionEvent.ACTION_POINTER_UP) {
        int pointer = (event.getAction() & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
        float x = event.getX(pointer);
        handleTouchEnded(view, x);
    } else if (action == MotionEvent.ACTION_MOVE) {
        int pointer = (event.getAction() & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
        float x = event.getX(pointer);
        handleTouchMoved(view, x);
    }

    return true;
}

On my phone (Samsung Galaxy S), this works flawlessly. For every handleTouchStart(), the appropriate handleTouchEnded() is called. This is crucial for my app. It’s a 2D sidescroller with a steering area in the left lower portion of the screen. If – for some reason – the handleTouchEnded() method is not called when the user lifts a finger from the touchscreen, the player’s character continues running.

I’ve received reports from players on other devices (like the HTC Desire) that in rare occasions, the character does indeed continue running in a direction even if they lifted their finger from the steering area on the screen. I concluded that this can only happen if handleTouchEnded() is not called which in turn means that no ACTION_UP (or ACTION_POINTER_UP) event is generated.

Are there device specific implementations of multitouch support? Is there no guarantee that for each ACTION_DOWN (or ACTION_POINTER_DOWN) MotionEvent, an appropriate ACTION_UP (or ACTION_POINTER_UP) MotionEvent is called? Or am I missing something? Is my onTouch implementation even correct?

My broader question would be: are there better ways to handle multitouch touchscreen input for “action”-games? I’m basically mimicking the left and right controls of a gamepad’s steering cross. I’ve found that Android’s UI buttons don’t offer enough flexibility because they can’t track onPress and onRelease events… or do they?

  • 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-05-22T01:49:38+00:00Added an answer on May 22, 2026 at 1:49 am

    You’re missing something. 😉 There is one more action type that you should handle: ACTION_CANCEL. ACTION_CANCEL is sent when the gesture in progress is aborted at some higher level – some higher-level component may have intercepted the gesture and taken it over, etc.

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

Sidebar

Related Questions

I have developed a framework that is used by several teams in our organisation.
I have developed some reusable android component which is basically a class . This
I developed an application that uses lots of images on Android. The app runs
I have developed android application. Now it is time to give it to the
I have developed a web application for mobile phones that uses JavaScript Google API.
I have developed an Android application and had it tested on emulator as well
I have developed an android service. Any android app can use it's API's to
I have developed an application that does require to do constant network activity. This
Hai Friends, I have developed an application which en-composes list views and posted that
How do you handle multiple screens in an android application? I have developed with

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.