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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:49:34+00:00 2026-06-07T22:49:34+00:00

i wan’t to code a live wallpaper, and i need a list of points

  • 0

i wan’t to code a live wallpaper, and i need a list of points that are currently pressed. I store the points in a SpareArray (basically the same than a HashMap, but faster).

Now, when i touch the screen with two fingers (1 and 2) and lift the fingers (first finger 2, than 1), it works. But when i lift finger 1 first, the app crashes. I have to lift my fingers in the reverse order then i pressed them.

@Override
public void onTouchEvent(MotionEvent event) {
    for (int i = 0; i < event.getPointerCount(); i++) {
        switch (event.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_POINTER_DOWN:
            case MotionEvent.ACTION_MOVE:
                int pID = event.getPointerId(i);
                Points.put(pID, new Point((int)event.getX(pID), (int)event.getY(pID))); //CRASH HERE
                break;
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_POINTER_UP:
                Points.remove(event.getPointerId(i));
                break;
        }
    }
    super.onTouchEvent(event);
    handler.post(drawRunnable);
}

I always get a “java.lang.IllegalArgumentException: pointerIndex out of range” exception

Thanks, Dominik

EDIT: stack trace

07-16 19:55:58.354: E/AndroidRuntime(4986): FATAL EXCEPTION: main
07-16 19:55:58.354: E/AndroidRuntime(4986): java.lang.IllegalArgumentException: pointerIndex out of range
07-16 19:55:58.354: E/AndroidRuntime(4986):     at android.view.MotionEvent.nativeGetAxisValue(Native Method)
07-16 19:55:58.354: E/AndroidRuntime(4986):     at android.view.MotionEvent.getX(MotionEvent.java:1974)
07-16 19:55:58.354: E/AndroidRuntime(4986):     at net.ta.livewp.LiveWallpaper$xEngine.onTouchEvent(LiveWallpaper.java:103)
07-16 19:55:58.354: E/AndroidRuntime(4986):     at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:1047)
07-16 19:55:58.354: E/AndroidRuntime(4986):     at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:61)
07-16 19:55:58.354: E/AndroidRuntime(4986):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-16 19:55:58.354: E/AndroidRuntime(4986):     at android.os.Looper.loop(Looper.java:137)
07-16 19:55:58.354: E/AndroidRuntime(4986):     at android.app.ActivityThread.main(ActivityThread.java:4575)
07-16 19:55:58.354: E/AndroidRuntime(4986):     at java.lang.reflect.Method.invokeNative(Native Method)
07-16 19:55:58.354: E/AndroidRuntime(4986):     at java.lang.reflect.Method.invoke(Method.java:511)
07-16 19:55:58.354: E/AndroidRuntime(4986):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
07-16 19:55:58.354: E/AndroidRuntime(4986):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
07-16 19:55:58.354: E/AndroidRuntime(4986):     at dalvik.system.NativeStart.main(Native Method)
  • 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-07T22:49:35+00:00Added an answer on June 7, 2026 at 10:49 pm

    I believe that you want to be calling event.getX(i) rather than event.getX(pID). getPointerId(i) returns a pointer identifier, rather than an index of a pointer, which is what you want.

    More information about this can be found in the MotionEvent docs

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

Sidebar

Related Questions

i wan to create a linked list that contains the name , age and
I wan to learn 1). How to call assembly code so that I can
I wan't to be sure that some piece of my code within the main
I wan't to divide my CI into multiple applications. I should say that it
I wan't to register the OnMouseOver and OnMouseOut-Event for an Image from the Code
i have uitextfield i wan that it should start entering text from top instead
I wan't to animate a view that's shaped as an arrow, and I want
I wan't to perform an animation before quitting a view. The problem is that
i wan to ask that if my machine got 1000/10000 of image and each
i wan to create a program that can get the application name i can

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.