Android - How to monitor the screen from a background process? - android

I would like to write a background process on Android to monitor the screen (not by taking screenshots).
I don't really need to record the screen; I want to process the frames and then perform some corresponding actions on the phone.
What is the way to do this ?
Root required?

So you want to snoop on somebody and make a keylogger,lol.The screen and all its stuff (buttons, frames,layouts) fires events when you mess with it. For example click on a button and a buttonClick event fires. If you change the orientation an orientation event fires. If your code wants to do something about an event you need to register an event listener. Most event listeners consume their events what you want to do is just take notice and throw the event. I hope this http://developer.android.com/guide/topics/ui/ui-events.html helps. Like I said if you add any "view" and by this I mean frame button etc a property change event will fire and you want to passively listen good luck

Related

How detect when finger pass on button and out of button holding finger down on the screen

When I try to drag my finger from one button to other, the first is released, the second is not pressed.
Practically I need the second to be pressed. I thought maybe there was some specific Listener to do this, but I could not find it.
Also, I would need to perform certain operations at the exact time that the button is released (banally, the color of the button can be stored in a local variable or in a text view as shown in the sample figure).
Sample Image
Thanks for the suggestions!
Have a look at the OnTouchEvent-Method. You could override it and listen for Motion Events like ACTION_HOVER_ENTER and ACTION_HOVER_EXIT.

Listen to all (device-wide) touch events in Android

I am working on a background service that runs to give sound feedback device-wide whenever the user is touching the screen. I tried to create an overlay with a custom view to listen to touches and pass them down to the views below in a similar direction to what was attempted in this question but my overlay seemed to be either consuming all the touch events or if I returned false only the down touch was detected.
I was wondering if there was perhaps an accessibility route I could take? Basically I need a way to get the information of any current touches on the screen (preferably multitouch) I don't need to alter the touch event or anything, just need the information.

Custom events corona sdk

I was wondering if I could use several events on one display table, like several custom events, touch events and enterFrame events.
If so, what are the restrictions? can I trigger an event inside an event response function?
As far as I know you can use an event inside event response function but it depends on what do you want to achieve for example an enterFrame can be trigger by a touch eventListener but some eventListener will need to complete it's function in order to trigger another eventListener like targeted events or collision event.
I haven't personally used all the events and listener so a may not cover all the restriction of it but you can refer to this link to know event and listener.
I achieved that in one of my projects. I used collision and touch event together and it worked great. So I assume that you can use events togetger. And also because of event structure its possible to triger one or more events together. ( Touching and colliding in the same time ). But I dont recommend to use enterFrame event with other events, because of performance issues
I needed to send a simulated touch event when a user pressed the menu button on an android device, and I was able to use dispatchEvent within the touch event handler
http://docs.coronalabs.com/api/type/EventListener/dispatchEvent.html

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.

Touch more one button at once

Hello i make appliction like Drum Studio. I need make support for touch more one button at once. For example: User touch button1(AND HOLD IT!) it play sound, but user still hold its, user click another button and it play sound too. How make it programmatically? By default onTouch or onClick use, if 1 button pressed, another buttons not react before button isn't released.
Use the onKeyDown() events to trigger each response and onKeyUp() events to finish them.
http://developer.android.com/reference/android/view/KeyEvent.html
http://developer.android.com/reference/android/view/KeyEvent.Callback.html
For touchs, you can use the OnTouchListener
http://developer.android.com/reference/android/view/View.OnTouchListener.html
and determine the kind of touch by the MotionEvent:
http://developer.android.com/reference/android/view/MotionEvent.html
To clarify my response: To make a sound while holding one button, you can start the sound when the ACTION_DOWN action in the MotionEvent event is triggered and stop it with the ACTION_UP action of the same event.
Create a class extending View where you're holding all your buttons.
Override the onTouchEvent vor that class.
Switch between the different actions.
Use event.getX() and event.getY() to figure out where the touch event was originated.
Check which button is located at that position
Play the sound accordingly.
You cannot touch two separate Views at the same time, even if multi-touch is supported on your device. If you touch Button1 first, all subsequent MotionEvents (including ones with separate pointer IDs) are bound to that View.
Unless you're using a dedicated game engine like AndEngine that has this sort of functionality built in, your only option is to capture all the MotionEvents yourself (most easily with an empty ImageView covering your entire screen) and route them to the appropriate Views based on their screen coordinates. This can get tricky, especially with multiple touch pointers, but the Android UI framework does not natively support the kind of multi-touch you require.
You definitely want to be using Android 2.0 or higher - previous versions don't support multitouch.
Check the pid in your onTouch - 0 is a single touch, 1 is the second.

Categories

Resources