Android simulate touch on other program - java

As u know, there are many solutions and codes on stackoverflow for simulating touch on your own app you are developing.
So my question is that i wanna touch a view on other application with my own application.
How can we do this?
Just imagine i wanna click on X,Y position of the screen each X seconds.

Generally speaking, you can't.
You are welcome to write an AccessibilityService. However, this has only limited ability to manipulate other apps, and it requires users to not only install your app but agree to allow your app to have wide access to all their existing app's UIs.

Related

libGDX as a "launcher" app

I have made a light weight java web-server serving html files and static content (made with pure java library nanohttpd), i have successfully made a javaFX launcher window that has a single button, clicking button simply runs the server in the background and opens the localhost URL in Android/PC browser (I was unsuccessful in making an IOS version using javaFX)
I am thinking of using libGDX as "launcher window" because of IOS support and access to mobile specific hardware like SMS/GPS which javaFX don't have.
I am targeting IOS/Android/PC, I'd like to ask libGDX developers how possible is this given my target platforms?
Yes you can
There's a catch though, you may have to build the UI the game dev way
I've made a game or two using it and had rather steep learning curve in the beginning to get a hold on to how it worked. For example you'll have to provide the images for button, background and also, the pressed view of the button... like that. But your app is not a game. So you won't have to worry that much.
Once you learned how to place them in the screen successfully, there is not much to worry about because the API provides everything you need to carry on from there.
Also I found enough resources/tutorials online enough to make a game from ground up. So you'll definitely can.
And there's very little to worry about your multi-platform problem.

Recording Touchscreen Interactions in Android outside Application

Is it possible to create a service that collect touch screen interaction data? I have seen that this could be possible in earlier versions of Android but seems to be much more difficult to achieve now. I have found many questions on Stack Overflow that already attempt this solution but don't offer a solution. The problem is also outlined here.
I wish to record the x and y coordinates of each tap and swipe interaction for medical analytics of different user groups. This includes recording scrolling data in (for example) the web browser. So far I can't get it to do this outside of the default application. How can I build a service for this?
I have tried adapting the code here, but nothing seems to work outside the application when other applications are running.

Detect screen-touch instances in background on android

I am currently working on a health-based project focusing on a person smartphone usage. And for that i want to monitor his touch-screen usage pattern i.e how long he has been pressing his hands on the screen.
When this limit crosses a thresh-hold value will be generated warning to him.
I need to know will i be able to track down a person screen-usage in background (i.e. while he uses all other apps in his phone)
If so which functions would help me ??
Android does not support this, for privacy and security reasons.
You are welcome to intercept all screen touches, to find out when the user touches the screen. However, then the screen touches will not be available to the underlying apps, and so user will not be able to use the device.
You are welcome to look at implementing an AccessibilityService, to be able to find out about user input in all apps. However, last I checked, this does allow you to find out "how long he has been pressing his hands on the screen".
You are welcome to create a custom Android ROM that bakes in your desired monitoring, then deploy that custom ROM on whatever devices you choose to support. With your own build of Android, you can do pretty much whatever you want, but then you are not making a simple app.
On a rooted device, you can probably run something with superuser privileges to track all user inputs, but I do not have the details about how to do that.
So far, there are similar questions asked in here as well. Most commonly, some users suggest defining a window layout stays on the screen as always and capture touch events with onTouch(View v, MotionEvent event) function. But it seems, it is not available anymore (after Android 5.0).
One thing I can suggest that, if the device is rooted, you can execute
"su getevent -lt" command and write the output in a BufferReader. That way you can capture the touch events.

Embed android application into other android application (Overlay + Events)

I was wondering if it's possible in android to embed an application into in another application. In this way you can have control of the embed application and you can add some other functionalities thanks to the parent application.
EDIT :
To be more accurate, I would like to have an application (parent application ) which can overlay the content of another application (embed application) without losing control of the parent application.
Thank you,
You can not specifically embed one app in another. And unless there is a specific inter-application API you have available to you, you cannot control the one app from your parent app either.
However if you just want to be able to view your parent app as some kind of overlay over another app, there are techniques that you might find useful.
It is possible to create an overlay view that can be seen when other apps are in the foreground. This is used by some chat clients, video playback, and task launchers. You can find some info on this method by looking at my answer here:
Background app to listen to Drag gestures
It is important to realise that in "the old days", a technique like this could be used to steal data from someone's phone. It was possible to receive taps & drags, and then pass them on to the other app.
This was a security hole, and has been fixed. So these days, you can choose if your overlay view should receive the taps or not i.e. if it is interactive, or just shows info.
Because of this, you will not want to cover up any of the "embedded" app with your own UI.
It is not possible any more to receive taps in your app, and pass them through to the other app.
This is not possible in general. The only thing that comes close is "embedding" an app widget in a home screen.

Developing a Java app that runs both on the web and as an Android app?

I'm working on a game which would work both on the web, as an applet, and on the Android phone, as an app.
Is that possible to do, and if so, what do I need to be aware of to make that work (i.e if there are any settings that I shouldn't hard code and instead determine them based on the user's device when the game is run, or any java libraries that I shouldn't use?).
Also, the game needs to accept touchscreen as input for the Android app. Is that possible to build into the same game which will also be run as an applet? May be so at run time, the applet decides whether to use Mouse or Touchscreen for the input when it is run?
Although Android apps are written in Java, the framework around the app is extremely different of the framework wrapped around an applet. You won't be able to have one .jar file that you can include as an applet and throw at an Android device because that's just not how it works.
You will however probably be able to create all the game logic and objects and have them in be shared with the applet code and android app. You can probably even get away with having them in one repository and project (although it's probably going to have to be an Android project that you then wedge in your app build scripts).
In order to tackle the different controls for your game you are probably going to have to abstract away the input, and have your game/level object have a call back like userHasPoked(int x, int y) and then have the applet call that method on click of the mouse and the android app calls it on touch (which is oddly still called onClick).
I think it'll be a long road, but much easier than rewriting the whole thing. It'll probably seem like a lot more work up front, but once you are done wedging your code into an applet and an Android app, you'll probably "never" have to touch that code again and can just keep adding to the game.
I wouldn't underestimate the task, but that sounds like a very fun programming exercise. Good luck!
What kind of game do you develop? It may be the better approach to develop an Javascript game.
That can be installed with phonegap (cordova) onto an android device.
Let me break this for you....
Model - The Business Logic and Data
View - The Display of the Output of the Model
Controller - On which the action is done.
The advantage of using this MVC architecture is that, you can keep the same model and keep changing the Views.
So keeping this idea in mind, you can have the same model for both the Web App and the Android App, and then implement each others Views to it respectively.

Categories