Android :: Motionevent - Multitouch Events Give Wrong Coordinates
Jan 6, 2010
I have been racking my brain to try to figure out what is going wrong here. I wanted to experiment with multi-touch, so I decided to add the controls for LunarLander to the touchscreen.
Instead of adding buttons, I defined regions on the screen that when touched, would act like the buttons on the keyboard (for example, the gas fires as long as you press the screen in the area defined for the gas button, and stops firing when you release.)
To do this, I added the onTouchEvent override to the LunarView class as follows:
CODE:.....................
View 2 Replies
Mar 17, 2010
I'm writing a simple tile based game using a canvas and a 5X5 grid of tiles. To determine if a tile is clicked I look at the MotionEvent supplied by onTouch. I get the coordinates when MotionEvent.event is ACTION_UP and translate to tiles. This works great on the emulator but when I touch on a device the actual coordinates of the touch register higher than I'd expect as a end user.
I'm wondering what strategies people have used to get a closer to "expected" result. Do you use a simple Y offset? Do you average the coordinates over the life of the touch? Do you use other methods?
View 4 Replies
View Related
Sep 26, 2010
I'm trying to get coordinates of the mouse, but there seems to be no easy ways. Can't make the MotionEvent object because the constructor is private. Can anyone please tell me how to get the coordinates of the touch/ pointer/mouse? I only want the touch coordinates of ImageView, but wouldn't mind the touch coordinates anywhere on the screen.
View 2 Replies
View Related
Sep 24, 2010
Purpose of the app:
A simple app that draws a circle for every touch recognised on the screen and follows the touch events. On a 'high pressure reading' getPressure (int pointerIndex) the colour of the circle will change and the radius will increase. Additionally the touch ID with getPointerId (int pointerIndex), x- and y-coordinates and pressure are shown next to the finger touch.
Following a code snipplet of the important part (please forgive me it is not the nicest code ;) I know)
CODE:.............
The problem:
A HTC Desire running Android 2.1 is the test platform. The app works fine and tracks two finger without a problem. But it seems that the two touch points interfere with each other when they get t0o close -- it looks like they circles 'snap'to a shared x and y axle. Sometimes they even swap the input coordinates of the other touch event. Another problem is that even though getPressure (int pointerIndex) refers to an PointerID both touch event have the same pressure reading.
As this is all a bit abstract, find a video here: http://www.youtube.com/watch?v=bFxjFexrclU
My question:
Is my code just simply wrong? Does Android 2.1 not handle the touch events well enough get things mixed up?Is this a hardware problem and has nothing to do with 1) and 2)?
View 1 Replies
View Related
Aug 25, 2010
I have a ListView that can have one or more clickable items. When I apply a rotate animation the coordinates that are clicked correspond to the original position of the ListView items. For example a list with one item in portrait mode rotated 180 degrees will have the item upside down on the bottom of the screen, but the item gets the click event when I click the top of the screen. 180 degrees is just an example I want to be able to move an arbitrary angle.
I've looked through all the listView properties but none seem to have any effect on the clickable coordinates. I would assume willChangeTransformationMatrix would do the trick but it doesn't, neither does invalidate or invalidateViews. Is there a property I'm overlooking or how would I go about moving the coordinates to the right place?
sample code- list items highlight correctly when clicked, rotate with dpad_center, after rotated items highlight when original position is clicked. I've tried animating the animation, animationSet, and layoutAnimationController all same result.
CODE:...............
View 1 Replies
View Related
Apr 29, 2010
I am attempting to write an application which will require the user to press, at maximum, four "buttons" (ie regions of the screen) at any one time. I have been looking at the multitouch capabilities of the SDK versions > 5, the MotionEvent.getPointerCount() appears to return the number of presses detected on the screen. *What is the maximum number of presses this function will ever return?*
I went digging through the android source code for the MotionEvent class, and couldn't deduce anything from that, I am wondering if the maximum number of presses is heavily hardware dependent? I modified the MultiTouchVis code by Robert Green (from Battery Powered Games) to report the number of presses reported by MotionEvent.getPointerCount() each frame and on my Milestone it consistently reports a maximum of 2 presses. Is this a hardware thing, or does the sdk limit it to 2 presses?
Is there any way to register more than 2 presses at a time? I'm making a musical application and would like the user, for example, to be able to play chords by pressing multiple keys at any one time.
View 2 Replies
View Related
May 13, 2010
Can multitouch events be tested on Android Emulator ? Or is there any way to test this without actual device ? I am using 2.0 sdk and want to test zoom-in zoom-out on by two fingers.
Is there a way out ?
View 4 Replies
View Related
Mar 5, 2009
I have a list activity that creates a header row above the data rows from the adapter. I want to receive click events when the user selects the header or a data row (but my data rows have check boxes in them, so this part is tricky). When I use the touch screen, I get this expected behavior:
1. Tapping on any row causes a click event and a dialog appears.
2. Long-pressing on a data row causes a context menu to appear.
3. Long-pressing on the header row does *not* show the context menu.
However, when I use the arrow keys (emulator) or trackball (G1), I get this unexpected behavior:
1. Selecting any row fails to cause any click events, even though the row's appearance changes like it's being clicked.
2. Long-pressing on the header row *does* show the context menu, which I don't want.
3. Occasionally, it doesn't focus the correct row when I move up or down (e.g. it skips from the header to the last data row).
View 11 Replies
View Related
Jun 30, 2010
I've been trying to write a little application that recognizes custom events in Android: you hold your finger over a TextView for a certain length of time, and it changes color.I'm using the MotionEvent coordinates and checking if they are within the bounds of a particular TextView, which is within a table.I am just attaching the onTouch listener to the table within the activity.But I get weird errors: the coordinates seem to be off by one view (i.e. if I touch the view below the view above reacts); or sometimes one will react, and the other will not. Any idea what might be going on?
View 2 Replies
View Related
Aug 5, 2010
i'm created an application where it consists of 3d rotating cube I want to move the cube with respect to the drag on the screen.In the on touch Listener I'm able to get the x,y coordinates but i don Know how to make those coordinates to map to 3d space.
View 3 Replies
View Related
Nov 14, 2009
I was expecting the getEdgeFlags() method of MotionEvent to tell me when a MotionEvent had reached the edge of something, but the value returned from getEdgeFlags() is *always* zero. Is this the expected behavior? The documentation says that the flags indicate when a touch has reached the edge of the display. I've tried this on a real device and in the emulator, and the location coordinates never quite reach the edge of the display, and getEdgeFlags() always returns 0. By "never quite reach" I mean that if dragging a finger off the left edge of the display, the smallest X I got was 2. Reaching the edge of the view doesn't seem to change the value returned either.
I suppose I could set the flags myself using setEdgeFlags() using calculations with known dimensions of the object whose edges I care about. Is that how it's supposed to be used? Is this broken for now?
View 3 Replies
View Related
Sep 10, 2009
Debugging on my G1 phone, I am trying to use android.view.MotionEvent.getPressure() and MotionEvent.getSize().
For MotionEvent.getSize(), I always get 0 (the documentation says it returns a value ranging from 0 to 1;
For MotionEvent.getPressure(), it seems to me this actually reflects the real finger touch size, as opposed to "pressure"; for me, I get values range from 0 - 0.63.
Am I missing anything or is it a known bug of the SDK?
View 4 Replies
View Related
Sep 3, 2010
I have a display that is 854x480 pixels. Why is it that the MotionEvent.getX and getY methods return floats? As far as I can tell, the pixels on the display are discrete integers, there is no such thing as a half a pixel on the display.
View 1 Replies
View Related
Sep 11, 2009
I am implementing OnTouchListener and am receiving MotionEvent objects. Some ACTION_MOVE events reports absolute X/Y coordinates, while some reports relative coordinates.
How can I ask a MotionEvent what kind of coordinates it currently represents?
View 3 Replies
View Related
Apr 9, 2010
I am having trouble getting my activity to generate a MotionEvent.ACTION_UP. Probably a beginner's error.
In LogCat, I'm only seeing the ACTION_MOVE event (which is an int value of 3). I also see the X/Y coordinates. No ACTION_DOWN and no ACTION_UP.
I looked everywhere for a solution. I found one question on a forum that seems to be the same as my issue, but no solution is proposed: http://groups.google.com/group/android-developers/browse_thread/thread/9a9c23e40f02c134/bf12b89561f204ad?lnk=gst&q=ACTION_UP#bf12b89561f204ad
Here's my code:
CODE:..........................
View 1 Replies
View Related
Jul 10, 2009
I need to have a left, right and click event in my App.
I am trying it like below:
CODE:...........................
View 2 Replies
View Related
Aug 22, 2010
I couldn't find a definite reference for the size of a MotionEvents history, when there are multiple pointers. The reference says that if you use a getHistorical* function, you might pass it a history position which is somewhere between [0..getHistorySize()-1]. But in a lot of examples handling multitouch if there are multiple pointers they only use history positions between [0..getHistorySize()/ getPointers()-1] (so they divide the history's size with the number of pointers). Which one is the correct way?
View 8 Replies
View Related
Oct 22, 2010
It seems like making any call to event.getHistoricalEventTime(int pos) when there is historical touch position data available makes my application crash. I've searched online and it seems like no one ever uses this method.
View 4 Replies
View Related
Oct 12, 2010
I'm working on a program which used the functions as title.
There's a problem that the tunctions above do not have their metrics on API website.
To avoid misunderstanding, here is an example about "metric" I metioned before.
Ex. size = pixel, pressure = kilogram(kg)
I have no idea about the metric at all.
View 1 Replies
View Related
Jul 20, 2009
My app forwards MotionEvents, reported by GestureDetector.OnGestureListener, to a worker thread. Right now i am doing it by calling MotionEvent.obtain, pass the obtained copy to the worker thread, handle it and recycle it at the worker thread. Is it required to obtain and recycle a MotionEvent if it is passed to another thread? Or could it safely be skiped? If i am making things overly complicated, could you please explain me at which conditions MotionEvent.obtain is usually called?
View 2 Replies
View Related
Jul 1, 2010
I am developing one application in which there is an imageview...in which i want to move left or right using mouse touch...for that i found "android.view.MotionEvent" but in MotionEvent there are few events among that ACTION_CANCEL 2. ACTION_DOWN 3. ACTION_UP ......etc.
Hence there is no such event for "LEFT" and "RIGHT" action....so is there any other way to implement the "LEFT" and "RIGHT" move ?
View 1 Replies
View Related
Apr 18, 2010
I'd really like to know what the state of that fix is as 2.1 is rolled out onto first generation (MSM7200-based) devices. As it stands, I don't see much of a problem with touch eating up CPU on the Droid and N1 but those are much faster phones so I don't think it would be quite as pronounced on them. My current 1.6 devices (G1 and Tattoo) cut my framerates in half during any touch (with the sleep hack, even). I optimized my new games so that they would run well-enough (25-40fps) on that hardware but they have very touch-centric interfaces so won't work well with that bug. I talked to a few people who run 2.0/2.1 mods on their G1s and they said the problem isn't any better. They still see the big slowdown. I tested on my 1.6 emulator vs a 2.1 emulator and there is a huge improvement. The 1.6 emulator slows down just like my G1 does and the 2.1 emulator shows only a tiny bit of slowdown, which is what I was hoping for. That's encouraging, but I have yet to see a real 2.1 MSM7200 update in the field so I don't know what to think yet.
View 10 Replies
View Related
Jan 3, 2010
I'm running into some issues with input events and garbage collection, or more precisely object allocation. I am creating a game and have pretty much got my head around the OpenGL environment. I've digested all the relevant material I could find regarding performance, memory allocation etc (and watched the excellent presentation by Chris Pruett - http://code.google.com/events/io/2009/sessions/WritingRealTimeGamesAn...). I've pretty much eliminated any object allocations after initial setup from my game (which is still in its infancy), but I'm still getting a bunch of GC calls, like this:...........................
View 6 Replies
View Related
Jan 25, 2010
I have added this line in my androidManifest.xml <uses-permission android:name="android.permission.INJECT_EVENT"/>
I am trying to execute following code:
CODE:........
Both above lines are throwing exception W/System.err(762): java.lang.SecurityException: Injecting to another application requires INJECT_EVENT permission.
Do we need anything else too to get it working ?
View 4 Replies
View Related
Nov 24, 2011
I have a relative layout built from XML.I am capturing the onTouchEvent.When I touch the screen anywhere except over the TableLayout or ImageButton
the MotionEvent.ACTION_DOWN and MotionEvent.ACTION_MOVE
events work fine.
how to make the onTouchEvent() work on the TableLayout and ImageButton views?
The purpose of the exercise was to have a drag method working over the relative layout,no
Maybe manipulating the layout_margin values? I was contemplating a transparent canvas overlay but haven't figured that out yet.
Code snippets below
XML
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"[code]......
View 2 Replies
View Related
Dec 17, 2009
Is there a way I can see my phone's raw GPS coordinates, i.e. decimal lat/long? Is it built-in, or is there "an app for that" ? I have an Eris Droid.
View 4 Replies
View Related
Oct 1, 2010
My Android app is experiencing this crash randomly during operation, and I think it is due to a pending MotionEvent that is dispatched to a null object, but not sure.
Here is the crash output:
CODE:.................
My Android app manually creates a custom WebView and adds it to the ViewGroup in the Activity.onCreate() method like this:
CODE:....
The reason for doing it this way was to be able to get to the constructor for the WebView in order to pass getApplicationContext() instead of this to the constructor, which was a workaround for a memory leak in 2.1.
The issue, I think, is that this Activity is restarted frequently. This causes the normal chain of onStop(), onDestroy(), onCreate(), etc... to happen often.
So my question is, could the crashes be due to a MotionEvent being dispatched to an instance of MyWebView that was attached to an old Activity that has been garbage collected? Such as if the user clicked something in a webview right before this actvity was recycled?
Another thing to note is I'm seeing these messages following a call to onDestroy() /webviewglue( 436): nativeDestroy view: 0xd738d0
This started happening in Android OS 2.2. I've submitted a bug to Google, but not sure it is their issue.
View 1 Replies
View Related
Jul 17, 2010
Can GPS on a phone, such as iPhone or Android determine your Z coordinates? I know it certainly has to be able to determine X and Y, well longitude, latitude that is, but what about the Z coordinates? Can it determine your height, and can I obtain height relative to ground?
View 3 Replies
View Related
Jul 8, 2010
I want to know if there is a way to be able to get the touch coordinates in an app. I know of the commands getRawX(),getRawY(),getX(),getY(). But they dont give me the exact coordinates. Shouldnt these coordinates be in the screen resolution range of the phone? or do they have a different range?
View 1 Replies
View Related
Apr 10, 2010
I have several tour guide books that list GPS coordinates for various sightseeing features.
Is there any way to enter these into Google Maps or Navigation as a destination? Is there an app that lets you do that?
View 2 Replies
View Related