Android Overlay doesn't dispatch events - android

So i wrote an Overlay with the WindowManager.LayoutParams.TYPE_PHONE Flag, everything seems to work as it should with the Problem that i want to align the Elements inside the Overlay on bottom of the Screen.
I did this via android:layout_alignParentBottom="true".
Now the Problem is that every touch event inside the Layout gets dispatched to me, while i only want the touches which hit my Controls. I tried calling return super.onTouchEvent(event); with no succes. Is there any way to return the touch events back to Android so they get handled properly?

Solved my Problem via the Interactive Overlay example, if you got the same or a similar problem the example might help you. http://www.jawsware.mobi/code_OverlayView/

Related

Passing clicks events from floating app to covered app

I have a floating app which works perfectly.
I am using OnTouchListener to catch events since I need to use the GestureDetector for swipes etc.
My only problem is that sometimes I wish to ignore certain events on the view.
In this case the view is invisible but not "gone" because I need it to accept certain gestures but not others.
I can't seem to be able to do that.
Returning false from "onTouch" simply doesn't work.
I checked that by experiment by disabling the GestureDetector and simply always returning false just to see what would happen. Result was nothing going through.
Is it even possible to pass a click through to a covered app?
Due to security reasons it's not possible to record and pass a click below (essentially allows building a keylogger).
Best you can do is have your floating window small enough to start the touch but not cover too much of the screen below.

Android Wear Overlay Pass on Touch Events

I have an Android Wear app in which I use a transparent overlay view to recieve touch events. I need to be able to receive all touch events that happen anywhere on the screen, and also be able to see their coordinates.
All research I have found says that I cannot recieve all touch events and pass them on. However, Wear Mini Launcher and Swipify are both doing something like this.
Here is where I have looked:
Android overlay to grab ALL touch, and pass them on?
https://stackoverflow.com/questions/19356834/overlay-view-which-intercepts-some-events
Android - Intercept and pass on all touch events
Android : Multi touch and TYPE_SYSTEM_OVERLAY
Creating a system overlay window (always on top)
Getting the View that is receiving all the touch events
Android Jelly Bean service that receives all touch events
TYPE_SYSTEM_OVERLAY in ICS
Overlay App that reacts only on some touch events
This must be possible to do somehow. Maybe an overlay view is not the right way to approach this? Any pointers?
I had quite a bit of trouble with this as well using the same links that you provided. But then I found this: http://www.piwai.info/chatheads-basics/
It's basically the same as the other solutions, except that the arguments to the WindowManager LayoutParams are TYPE_PHONE and FLAG_NOT_FOCUSABLE.
Not only did this solution work for me (I was testing on an LG Urbane), the onTouchEvent callback had all the actions (down, move, and up), which the other solutions said you wouldn't get.
Since all the touch events are passed through the view, in theory we can use gesture detectors to get callbacks for things like double taps and flings. I haven't tried this yet, though.
Regardless, the above link should get you past the initial problems you're facing.

Single touch in ANDROID

Is it possible to allow the user to touch the screen only once?
Meaning: A user touches the screen and if he tries to touch the screen again nothing will happen. I am implementing the approach using canvas to draw the objects on the screen.
Thank you in advance!
From what you have in mind, setClickable() or onTouchEvent would be the best way to go.
Have a look on this reference:
Responding to Touch Events
Disable All Touch Screen Interactions While Animation
setEnabled() vs setClickable(), what is the difference?
As commented above - use a boolean variable as a flag and toggle it between true and false according to how the user interacts!

Android - touch two buttons at same time

What is the best way to touch two buttons at the same time? I am working on an app that has buttons, like a D-pad and a jump button, to move your character around. Right now I am just using normal buttons and handling them with an OnClickListener. I am having problems when I am running and need to jump at the same time, or if I am running to the right, then want to go left without having to pick my finger up. I know this is possible because it works greats on game like Sonic CD and some others. Any help would be greatly appreciated.
OnClick fires only on release. Instead use the touch event handlers so that when they touch occurs, you get the events. However, note that not all devices have multitouch, and thus not all of them will be able to handle the double-touch case correctly. They will provide touch events, but not two of them. Also note that you may receive multiple "pointers" within a touch event, and will have to decide which is "yours" for each button if that matters.

Zoom controls not appearing after first click, for later clicks

My problem is that the zoom controls don't appear on the mapview after one click, i.e the first click after the application loads. (I am using the deprecated version.)
In my application, on a click I position a pushpin on the touched location and also generate a toast with the co-ordinates. After I click the map, the pin is re-loacated and the toast are generated (albeit a bit late, I guess because of the time for which they have to say on screen)
What is happening wrong? What gives? Are the two activities (pin and toast) stealing the touch event?
Can you suggest any alternatives?
I solved it myself, i had to add
mapView.displayZoomControls(true);
to the function that handled all the click events. but now it doesnt pan. ill see what i can do about it.
thanks.

Categories

Resources